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

查看:167
本文介绍了远程调试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. 选项位于类名之前。类名后面的任何参数都是程序的参数!

  1. No spaces in the runjdwp option.
  2. Options come before the class name. Any arguments you have after the class name are arguments to your program!

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

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