Starting with JRebel Agent

Assuming that the target application already has JRebel Agent and Java Debug Agent specified in the command line:

java -agentpath:/some_path/jrebel/lib/libjrebel64.so -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8188 -classpath myclasses.jar com.mycompany.myapp.Main

To start JRebel Debugger Proxy (JDP) with the target application, add =dbgproxyport=<proxy port no> to the end of the -agentpath:..jrebel... JVM argument. For example:

java -agentpath:/some_path/jrebel/lib/libjrebel64.so=dbgproxyport=9199 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8188 -classpath myclasses.jar com.mycompany.myapp.Main

In the example above, the proxy port (9199) must be different from the JDWP port (8188). It must also be available (no other process on the host can be listening on it).

The JRebel Agent native library starts the JDP. JDP will listen on the proxy port (9199) and forward the JDWP traffic to the JDWP port (8188) of the target process.

To confirm that the JDP is active, check for the following line at the beginning of the target process stdout:

Proxy listening on port 9199 and will connect to localhost:8188

Similar log lines should also be present in ~/.jrebel/bootcache/jrebel.boot.log or <rebel.base>/bootcache/jrebel.boot.log if -Drebel.base=... was specified in the command line, or ${REBEL_BASE}/bootcache/jrebel.boot.log if the REBEL_BASE environment variable is defined:

JRebel-JVMTI [DEBUG] Debugger proxy port: 9199
JRebel-JVMTI [DEBUG] JDWP port: 8188
JRebel-JVMTI [DEBUG] java.home is /Users/myuser/.sdkman/candidates/java/21.0.6-tem
JRebel-JVMTI [DEBUG] using java executable /Users/myuser/.sdkman/candidates/java/21.0.6-tem/bin/java
JRebel-JVMTI [DEBUG] Jar locatiom: /Users/myuser/IdeaProjects/SidecarTestbed/jrebel/
JRebel-JVMTI [DEBUG] Debugger proxy: /Users/myuser/IdeaProjects/SidecarTestbed/jrebel/jr-debugger-proxy.jar
JRebel-JVMTI [DEBUG] In debugger proxy runner thread
JRebel-JVMTI [DEBUG] Executing [/Users/myuser/.sdkman/candidates/java/21.0.6-tem/bin/java, -Drebel.base=./rebel_base, -Drebel.parent.pid=98819, -jar, /Users/myuser/IdeaProjects/SidecarTestbed/jrebel/jr-debugger-proxy.jar, 9199, localhost, 8188]
JRebel-JVMTI [DEBUG] Child PID: 98820

The following situations are handled automatically:

  • If JDP terminates while the target process is running, the JRebel native agent will restart JDP.

  • JDP terminates itself if it detects that the target process has been terminated.