简体   繁体   中英

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:

我的应用程序调试

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:

在此处输入图片说明

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

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; eg

-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.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM