远程调试Java应用程序

编程入门 行业动态 更新时间:2024-10-10 05:16:23
本文介绍了远程调试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

这里有两点:

  • runjdwp 选项中没有空格。
  • 选项位于类名之前。类名后面的任何参数都是程序的参数!
  • No spaces in the runjdwp option.
  • Options come before the class name. Any arguments you have after the class name are arguments to your program!
  • 更多推荐

    远程调试Java应用程序

    本文发布于:2023-11-25 06:02:54,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1628610.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:应用程序   Java

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!