Fork me on GitHub

Introduction

This plugin embeds java agents into an executable JAR file, executing them automatically during application start on JRE 9+.

An executable JAR has a Main-Class attribute in its manifest and is executed by java ‑jar my.jar.

Normally, you would need additional ‑javaagent:/path/to/agent.jar JVM arguments to start one or more java agents, but since Java 9 there is the Launcher-Agent-Class mechanism, which can launch a java agent from inside the executable JAR, if the agent classes are part of the JAR. I.e., even though this plugin works just fine on Java 8, you do need to launch the modified executable JAR on JRE 9+ to enjoy the benefits of this JVM feature.

See the usage and plugin info pages for more details about how the plugin works and how to configure it.

Unique plugin features not offered by the Java 9+ Launcher-Agent-Class mechanism:

  • Out of the box, the JVM only supports a single agent for auto-start, not multiple ones. Multiple agents can only be specified on the JVM command line. But this plugin installs its own launcher agent, which in turn is capable of starting multiple java agents.

  • The JVM does not support agent option strings for embedded agents like the JVM command line does. This plugin, however, does support agent arguments via its launcher agent.