0

I have written a Java 17 application that provides several MBeans. If I start the jar with a standard Java 17 SDK via java -jar myjar.jar the applications starts and I can connect to it from JConsole.

Then I have created a custom runtime image with jlink.

The application itself runs fine with this image. It gets the MBeanServer and registers successfully my MBean.

When I start Jconsole I can select the running application (as "Local Process") but then the connection to this process can't be created.

I have tried to add a number of additional modules (like jdk.management, java.management, ...) but without success. It seems that at least one module is missing because in my customer runtime image e.g. the DLL management_ext.dll is missng.

Any idea which modules are necessary?

2 Answers2

0

Try use jdeps to check all modules are required in your build.

Example of listing all modules from .jar

jdeps --ignore-missing-deps --print-module-deps --multi-release 17 your-jar.jar 

Example to jlink

jlink \
    --module-path /path-with-all-jdk-modules \
    --add-modules $(jdeps --ignore-missing-deps --print-module-deps --multi-release 17 your-jar.jar ) \
    --output /path-output-jre-custom \
    --strip-debug \
    --no-header-files \
    --no-man-pages \
    --compress 2

Dilermando Lima
  • 1,004
  • 8
  • 21
  • According to jdeps only `java.base` and `java.management` are necessary. The application can be executed with only these modules, but jconsole can't connect. I am also quite sure that the DLL `mangement_ext.dll` is needed, but it is not part of the runtime image created by jlink. – Martin Herbst Nov 24 '22 at 14:35
0

I had to add jdk.management.agent. That added management.dll and management_agent.dll. The management_ext.dll doesn't seem to be necessary.