Yes! Here is how you set it up.
Create a Remote run configuration:
- Run -> Edit Configurations…
- Click the “+” in the upper left
- Select the “Remote” option in the left-most pane
- Choose a name (I named mine “remote-debugging”)
- Click “OK” to save:
The configuration above provides three read-only fields. These are options that tell the JVM to open up port 5005 for remote debugging when running your application. Add the appropriate one to the JVM options of the application you are debugging. One way you might do this would be like so:
But it depends on how your run your application. If you’re not sure which of the three applies to you, start with the first and go down the list until you find the one that works.
You can change
suspend=y to force your application to wait until you connect with IntelliJ before it starts up. This is helpful if the breakpoint you want to hit occurs on application startup.
Start your application as you would normally, then in IntelliJ select the new configuration and hit ‘Debug’.
IntelliJ will connect to the JVM and initiate remote debugging.
You can now debug the application by adding breakpoints to your code where desired. The output of the application will still appear wherever it did before, but your breakpoints will hit in IntelliJ.