Connecting to the JMX Agent Programmatically in Java 9

1.3k views Asked by At

I need to connect to JMX agent programmatically using Attach API (loading agent at runtime if necessary) as shown in example here. This worked fine in Java 8 but doesn't work in Java 9 since there is no management-agent.jar in the lib folder anymore:

String agent = vm.getSystemProperties().getProperty("java.home") +
   File.separator + "lib" + File.separator + "management-agent.jar";

Could you please advice what is the right way to do that in Java 9?

Thanks in advance, Vadim

1

There are 1 answers

0
Alan Bateman On BEST ANSWER

Yes, management-agent.jar has been removed (see release note). If you looking to start the management agent then look at the new startManagementAgent and startLocalManagementAgent methods in com.sun.tools.attach.VirtualMachine.

The "Setting Up Monitoring and Management Programmatically" section in the JDK 9 docs needs to be updated.