How do I start my Java program with more than one java agent?

Flueras Bogdan picture Flueras Bogdan · May 16, 2009 · Viewed 45.2k times · Source

I'm aware of how to start a java progam with a java agent:

java -javaagent:myAgent.jar MyJavaProgram

But what if I want to add 2 or more java agents to instrument my program? I do not want to reinvoke the java -javaagent:... for every agent I have to load in JVM.

I've tried something like this :

java -javaagent:agentA.jar, agentB.jar MyJavaProgram

or something like this:

java -javaagent:agentA.jar agentB.jar MyJavaProgram

But have no success.

Is there an answer to solve my problem ?

Thank you.

Answer

Tahir Akhtar picture Tahir Akhtar · May 16, 2009

How about two javaagent parameters?

java -javaagent:agentA.jar -javaagent:agentB.jar MyJavaProgram