aCarella
aCarella

Reputation: 2558

Cannot debug Java application with Eclipse

I have a Java (Vert.x) application on my machine that I am trying to attach Eclipse to for debugging.

I usually start the Java application in my console like so:

java -jar build/libs/my-app.jar

Upon reading about debugging, I am attempting to start the app as follows:

java -jar build/libs/my-app.jar -Xdebug -Xrunjdwp:transort:transport=dt_socket,address=8001,server=y,suspend=n

The app seems to start up in the console fine when I run this.

I then go into Eclipse, and try to connect to the app via debugging via Run -> Debug Configurations. This is what my debug configuration looks like:

my-app debugging

When I click debug, I get an error box that pops up and says that the connection is refused (I covered the name of my real app). See below:

enter image description here

What am I doing wrong? How can I get remote debugging to connect to my app with Eclipse?

Upvotes: 0

Views: 932

Answers (1)

Stephen C
Stephen C

Reputation: 718678

According to my reading of this JDWP documentation, your -Xrunjdwp option is incorrect:

-Xrunjdwp:transort:transport=dt_socket,address=8001,server=y,suspend=n

should be

-Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n

If your system has multiple IP addresses, there could be some confusion about which IPs the agent is listening for connections on. You could force a specific address; e.g.

-Xrunjdwp:transport=dt_socket,address=127.0.0.1:8001,server=y,suspend=n

and use the matching IP and port in the Eclipse debug connection parameters.


AND ... as Dave Thompson spotted ... all JVM options must be placed before the -jar argument. (Anything after the -jar name.jar will be treated as command line arguments for your application.)

Upvotes: 3

Related Questions