I've found many answers pointing me to VirtualMachine#loadAgent
, which would honestly be great, except I don't have a VirtualMachine class, anywhere. I've been quite confused about it as well, however I do not seem to have any of the Attach API. I am using OpenJDK 8:
$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b05)
OpenJDK 64-Bit Server VM (build 25.222-b05, mixed mode)
What other methods are there to load a java agent? The environment I am working in would have very little success at passing -javaagent:
arguments, as it's meant to be injected into the classpath at runtime, and obviously any average user isn't going to want to/have the knowledge to manually change the JVM args just for my specific program.
On another note, just to make sure that this class is meant to be a part of OpenJDK, as isn't something designed only for the java hotspot VM, I downloaded OpenJDK code from http://hg.openjdk.java.net/, and found the VirtualMachine.java file, which means that it definitely is meant to exist