Questions tagged [javaagents]

A Java agent allows for the instrumentation of a Java application by using another Java program that is specified on the command line.

All Java classes concerned with instrumentation are collected in the java.lang.instrument package. The package description defines the layout of a Java agent as follows:

An agent is deployed as a JAR file. An attribute in the JAR file manifest specifies the agent class which will be loaded to start the agent. For implementations that support a command-line interface, an agent is started by specifying an option on the command-line. Implementations may also support a mechanism to start agents some time after the VM has started. For example, an implementation may provide a mechanism that allows a tool to attach to a running application, and initiate the loading of the tool's agent into the running application. The details as to how the load is initiated, is implementation dependent.

538 questions
97
votes
4 answers

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

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…
Flueras Bogdan
  • 9,187
  • 8
  • 32
  • 30
57
votes
2 answers

Tutorials about javaagents

I'd like to learn something about javaagents, but researching is not easy. Most of result refers to JADE. I know java agent can mean two things: An agent programmed in Java being an incarnation of the agent concept of distributed systems. A…
alicjasalamon
  • 4,171
  • 15
  • 41
  • 65
27
votes
4 answers

Starting a Java agent after program start

Is it possible to insert a javaagent after virtual machine start from within the same VM? Lets say for example we have an agent in a jar myagent.jar with the appropriate meta data set-up and an agentmain method already implemented. Now the users…
Paul Keeble
  • 1,202
  • 2
  • 12
  • 16
23
votes
4 answers

How can I add a Javaagent to a JVM without stopping the JVM?

I wish to profile a Java application without stopping the application. Can I add a Javaagent somehow while the application is running?
yazz.com
  • 57,320
  • 66
  • 234
  • 385
18
votes
1 answer

How do I pass arguments to a Java instrumentation agent?

How do I pass arguments to a java.lang.instrument instrumentation agent? The documentation simply states: -javaagent:jarpath[=options] What options can I select?
Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
18
votes
1 answer

Cassandra:The stack size specified is too small, Specify at least 228k

I'm getting this error when starting cassandra after upgrade. Any idea? # cassandra -f xss = -ea -javaagent:/usr/share/cassandra/lib/jamm-0.2.5.jar -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms1920M -Xmx1920M -Xmn200M…
Harikrishnan
  • 9,688
  • 11
  • 84
  • 127
17
votes
5 answers

How to put classes for javaagent in the classpath

I am trying to develop a javaagent that would instrument code with help of asm-4. For now I'm stucked with a pretty basic problem, the classloader for the javaagent doesn't see asm dependencies and therefor fails. Do I have to provide a…
Leon
  • 1,141
  • 1
  • 10
  • 25
15
votes
3 answers

Difference between redefine and retransform in javaagent

When packing a jar file with custom java agent, you can add the following properties: Can-Redefine-Classes Can-Retransform-Classes What is the difference between those two? If redefinition happens before class is loaded and retransformation after,…
Average Joe
  • 643
  • 5
  • 15
15
votes
3 answers

Specify javaagent argument with Maven exec plugin

I have a similar question to: this previous question I am converting a Java project using Netbeans to Maven. In order to launch the program, one of the command-line arguments we need is the -javaagent setting.…
David I.
  • 4,747
  • 3
  • 26
  • 34
14
votes
3 answers

C++ jump to other method execution

In my C++ JNI-Agent project i am implementing a function which would be given a variable number of parameters and would pass the execution to the other function: // address of theOriginalFunction public static void* originalfunc; void*…
Aksim Elnik
  • 425
  • 6
  • 27
12
votes
3 answers

Relocating AspectJ packages in a Java agent

I'm using AspectJ to monitor field access and field modify. I have a gradle project that compiles the two aspects and package that jar together with the aspectjrt and aspectjweaver in a shaded jar using gradle shadow plugin. the agent is still…
Shalom938
  • 909
  • 2
  • 10
  • 24
11
votes
3 answers

Adding -javaagent to Tomcat 6 server, where do I put it and in what format?

I´m trying to install an application health monitoring application that can monitor J2EE web transactions and I need to put a javaagent into my Tomcat somehow but am not clear on exactly how to do this, I am using Linux and have been instructed by…
Rick
  • 16,612
  • 34
  • 110
  • 163
11
votes
5 answers

VirtualMachine.attach(pid) fails with java.io.IOException: Can not attach to current VM

After going through this discussion, I'm led to believe the option to attach to the same VM, by default has been disabled in OpenJDK11. I'm trying to upgrade a java agent to OpenJDK11, during the test cases when VirtualMachine.attach(pid) is called…
Vivek Shankar
  • 770
  • 1
  • 15
  • 37
11
votes
1 answer

What is the use of agentmain method in java instrumentation

I done some java bytecode instrumentation with -javaagent argument and premain method. But this is the first time i hear about agentmain method. I have some questions about this method. Here follows it. Both premain and agentmain method have same…
Anish Antony
  • 875
  • 3
  • 17
  • 35
10
votes
4 answers

Java - Inject java agent in to running jvm

Basically, I am trying to write something that lists every class loaded by the JVM. What I wrote works, but it only works for the jvm it is running on. I crafted a java agent to dynamically inject into another JVM, but then realized I don't actually…
Stoud
  • 283
  • 1
  • 7
  • 15
1
2 3
35 36