I had few stand alone java processes running that are not started from the IDE which I had to debug from IntelliJ, it took quite some time for me to figure out how to do that, so I thought will blog it for people who might need it.
It’s quite simple all you have to do is, run the java process which ever you want to debug using the following flags for java command.
$ java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9995 RemoteProcess
9995 is the port on which the IntelliJ will hook on to your remote java process for debugging information. This can be any port as long is it is not being used by other process.
RemoteProcess is a stand alone java process which you want to debug.
Once the java process is up and running, here is what you need to do in IntelliJ to start debugging that process.
Make sure you have the code base of the java process you are running opened in the IDE, go to Run -> Edit Configurations which opens up the config window as shown below.
Click on the + symbol on the top left corner of the window, which prompts you to select one of the different available configurations, select Remote from the given list as shown in the picture below.