Switching JRebel Agents

JRebel comes bundled with two agents – the JRebel Agent and the Legacy Agent (which can be found in the legacy folder). Unless configured, JRebel defaults to using the JRebel Agent.

You can switch back to the Legacy Agent when necessary. This can be done from the IDE settings (when using a JRebel IDE plugin) or from the command line.


When running your server or application via IDE

  1. Open Help > JRebel > Configuration.
  2. Find the Advanced tab.
  3. Select the option to use Legacy Agent.
  4. Restart your application server.

Note

If you need to switch back to the newer JRebel Agent, access the Advanced tab again and select JRebel Agent. Do not forget to restart your application server after that.


When running your server or application from a command line

To enable the Legacy Agent for standalone applications, you need to add the library using either -agentpath or -javaagent JVM options.

Note

Two JRebel Agents are provided when downloading the standalone ZIP file:

  • ./jrebel.jar – This is the JRebel Agent.
  • ./legacy/jrebel.jar – This is the Legacy Agent.

Switching JRebel Agents on Windows, Mac OS and Linux

Add -agentpath:[path/to/jrebel] to the JVM command line.

Operating system Startup command
Windows 64-bit JDK java -agentpath:c:\JRebel\lib\jrebel64.dll com.example.Main
Windows 32-bit JDK java -agentpath:c:\JRebel\lib\jrebel32.dll com.example.Main
Mac OS X 64-bit JDK java -agentpath:/Users/user/jrebel/lib/libjrebel64.dylib com.example.Main
Mac OS X 32-bit JDK java -agentpath:/Users/user/jrebel/lib/libjrebel32.dylib com.example.Main
Linux 64-bit JDK java -agentpath:/Users/user/jrebel/lib/libjrebel64.so com.example.Main
Linux 32-bit JDK java -agentpath:/Users/user/jrebel/lib/libjrebel32.so com.example.Main

Switching JRebel Agents on other operating systems

Add -javaagent:/path/jrebel.jar and -Xbootclasspath/p:/path/rebelboot.jar to the JVM command line.

During the first run this command, it will build a boot cache that enables JRebel to operate during following runs. The boot cache JAR file will be generated into the path specified in the -Xbootclasspath/p JVM argument.

Note

Changing the JDK used or upgrading JRebel invalidates the boot cache. When changing the JDK or JRebel version, you need to delete rebelboot.jar. In rare cases, changing the JVM arguments can result in JVM crashes. This can be resolved by deleting the boot cache and regenerating it.

  • Using this method on Windows – java -javaagent:c:\JRebel\jrebel.jar -Xbootclasspath/p:c:\JRebel\bootcache\rebelboot.jar com.example.Main
  • Using this method on Linux and Mac OS – java -javaagent:/Users/user/jrebel/jrebel.jar -Xbootclasspath/p:/home/user/jrebel/bootcache/rebelboot.jar com.example.Main

Note

If you run without setting -Xbootclasspath/p, JRebel will still generate a boot cache for you on the first run. It will then print out where this cache is located as well as the exact -Xbootclasspath/p argument that you should pass to JVM arguments to run with this boot cache.