远程调试 Java 应用程序 [英] Remote debugging a Java application

查看:30
本文介绍了远程调试 Java 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 linux 机器上运行的 java 应用程序.我使用以下命令运行 java 应用程序:

I have a java application running on linux machine. I run the java application using the following:

java myapp -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000, suspend=n

我在这台 Linux 机器上为 TCP 打开了端口 4000.我使用 Windows XP 机器上的 eclipse 并尝试连接到此应用程序.我也在 windows 中打开了端口.

I have opened port 4000 for TCP on this Linux machine. I use eclipse from Windows XP machine and try to connect to this application. I have opened the port in windows also.

两台机器都在局域网上,但我似乎无法将调试器连接到 Java 应用程序.我做错了什么?

Both machines are on the LAN but I can't seem to connect the debugger to the Java application. What am I doing wrong?

推荐答案

我注意到有些人正在这里剪切和粘贴调用.我最初给出的答案仅与 OP 相关.这是一种更现代的调用方式(包括使用更传统的 8000 端口):

I noticed that some people are cutting and pasting the invocation here. The answer I originally gave was relevant for the OP only. Here's a more modern invocation style (including using the more conventional port of 8000):

java -agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n <other arguments>

原始答案如下.

试试这个:

java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n myapp

这里有两点:

  1. runjdwp 选项中没有空格.
  2. 选项位于类名之前.在类名之后的任何参数都是程序的参数!

这篇关于远程调试 Java 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆