Search code examples
javajvmjvm-argumentsjavaagentsjvmti

How to set -javaagent differently?


I need to load a java agent without setting -javaagent. The reason why I need to do this is I have an exe that starts a JVM with command line args specified in a file. This exe filters -javaagent. How can I do this? I must load this agent via a command line argument, not via attachment later on.


Solution

  • "Try to set JAVA_TOOL_OPTIONS or _JAVA_OPTIONS environment variable. JVM should append the arguments from these variables, unless the executable also changes the environment. – apangin"

    Thank you! Your answer worked. I set the environment variable temporarily in the command prompt. When the application was started from within the command prompt, the JVM accepted the JAVA_TOOL_OPTIONS temporary environment variable and loaded the -javaagent successfully.