Remote JVM debug
This article describes how to debug a Java application which is running on remote server.
We have two things to do:
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:
After that just run new configuration:
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: