Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jvm

javaagents

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.

like image 811
Flueras Bogdan Avatar asked May 16 '09 15:05

Flueras Bogdan


People also ask

Can I have multiple Java agents?

The -javaagent option may be used multiple times on the same command-line, thus starting multiple agents. The premain methods will be called in the order that the agents are specified on the command line. More than one agent may use the same <jarpath> .

How do Java agents work?

Java agents are a special type of class which, by using the Java Instrumentation API, can intercept applications running on the JVM, modifying their bytecode. Java agents aren't a new piece of technology. On the contrary, they've existed since Java 5.

How do I start a Newrelic Java agent?

Sign up for a New Relic account. Install the Java agent using our launcher, or by following the standard installation procedures. Depending on your tools and frameworks, refer to additional installation procedures to install or configure the Java agent.


1 Answers

How about two javaagent parameters?

java -javaagent:agentA.jar -javaagent:agentB.jar MyJavaProgram 
like image 79
Tahir Akhtar Avatar answered Oct 06 '22 11:10

Tahir Akhtar