tags:

views:

590

answers:

2

Hello,

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.

+2  A: 

It would appear you can do this by using multiple args. From the doc

On implementations with a command-line interface, an agent is started by adding this option to the command-line:

-javaagent:jarpath[=options]

jarpath is the path to the agent JAR file. options is the agent options. This switch may be used multiple times on the same command-line, thus creating multiple agents. More than one agent may use the same jarpath. An agent JAR file must conform to the JAR file specification.

(my emphasis)

Brian Agnew
Yes, you're right!
Flueras Bogdan
A: 

how about two javaagent parameters

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