Reputation: 2180
I have different Java applications running on my system and want to instrument classes from one of these applications
While trying to do this using dynamically loaded Java agent I found that we can attach it to a jvm
instance which requires vm
id
of that jvm
instance when I put a pid
of an already running Java application by searching from windows task manager the agent jar does not attach to this process and a error is thrown.
While doing it using ManagementFactory.getRuntimeMXBean()
the process id()
returned is that of the instance loading the agent.jar
. kindly suggest how to access a vmid
of a different jvm
instance
Upvotes: 3
Views: 123
Reputation: 41945
You can use scripts for executing the JPS command and extract the information regarding the VM instances being run.
Also the jps command uses MonitoredHost API which has activeVms() method.
Upvotes: 1