Aamir
Aamir

Reputation: 2424

How to debug a .jar file remotely using Intellij Idea

I am currently using intellij idea to code my project that I am working on, after creating of .jar file using OneJar command i deploy the .jar file on my linux server who address is something like 192.164.1.125.there I run the command sudo nohup java -jar fileName.jar & on server to start the jar file in the background and use the rest-client app to send rest calls to my .jar file.Whenever something goes wrong I can only see error message in nohup.out file and what I actually wanted is to debug my jar file using intellij idea i.e how can I debug my .jar running on 192.164.1.125 using intellijIdea running on my client machine.I know I have to use that EditConfigurations option in run menu of intellij and provide IP and Port, but how to do it exactly.

Upvotes: 3

Views: 11491

Answers (2)

jeevan
jeevan

Reputation: 81

You can do the remote debugging on IntelliJ IDEA 2019.2 version very easily!

  • Click on "Run" -> "Edit Configurations"
  • Click on "+" and select "Remote"
  • Enter your remote IP and select source code folder path
  • Optional : change the name and port of your wish

enter image description here

  • Run your remote server jar with the command which is mentioned in the Command line arguments for remote JVM box . something like this,

    sudo nohup java "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8911" -jar fileName.jar &

  • You are all set. add the breakpoints and click on Debug symbol to debug your remote jar from local

Upvotes: 5

You must run the remote "java -jar .." command in debug mode by adding the additional magic flags. You can then tell your local IntelliJ to create a new debug configuration targeting a remote application - IntelliJ provides the magic flags you need.

The help page for this feature is at https://www.jetbrains.com/idea/help/run-debug-configuration-remote.html

Upvotes: 0

Related Questions