New Relic did not create, nor is it the only, or even first to use -javaagent. A javaagent is a Java Programming Language Feature that was introduced in Java 5.
New features were introduced to the javaagent in Java 6 that are utilized by the New Relic Java Agent starting in version 3+. This is why you must use New Relic Java Agent version 2.x for any application running Java 5 (or the JRockit JVM).
In order to support Java 10, support for Java 6 was deprecated in Agent v4.4.0. Making Agent v4.3.0 the last version compatabile with Java 6.
Java programs start with the main() function. A javaagent is given special permission by the JVM to run a premain() function that executes before the main().
It is in this premain() function that New Relic developers work and from there designate how supported framework are instrumented.
This is how the NR Java Agent is able to work on so many “non-supported” frameworks. The most important thing in installing the New Relic Java Agent is simply passing the -javaagent flag into the JVM. The method for doing this is dependent on the framework/app server. All of our installation instructions are simply ways to pass the
-javaagent:/path/to/newrelic.jar into your JVM’s arguments. In the vast majority of cases, this can be done where the Heap options are set.
As the ways that Java Options can be passes into the JVM are literally infinite, if you need additional assistance in appropriately passing the flag in your environment, the developer of that environment would be the best resource.
You can verify that the -javaagent flag is passed into the JVM by performing step 3 in the doc here:
Using the New Relic Java Agent in an environment that we don’t have listed? Tell us how you got it running below!
updated: March 10, 2020