Remote JVM debug

This article describes how to debug a Java application which is running on remote server.
We have two things to do:
  • enable and specify debug port on JVM which is running our app,
  • connect to that JVM.



In this example let's expose port 8083 for debuging by adding this flag for our JVM:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8083
command for running our app should look like that:
java -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8083 app-name.jar



Now let's connect to that JVM. I will use IntelliJ IDE for that. First step is to create new configuration of "Remote JVM Debug" type:




Next, the remote address and port have to be specified. I'm running my application on localhost and exposed debug port is 8083:







 


After that just run new configuration:



 




Debug console should show information that remote debugger was connected to app:









When debugging a remote app a good practice is to avoid "stop the world" for other users, if it's possible. To achieve that just right click on just debug point and select to suspend "Thread" instead of "All". You can also make that default for future usages:




Popular posts

Basic AKHQ running with docker (HTTP)

AKHQ login with Keycloak

Running keycloak in 4 minutes for development on Windows