在unix中调试Java应用程序-附加一个分析器或调试器



我的目标是将Java分析器或调试器附加到由一个名为Nuix的Windows应用程序启动的Java虚拟机实例上。

可以将命令行开关传递给unix,其中一些传递给JVM。

unix与JRE 8一起打包在其子目录之一:Nuix 7.4jre中。该版本为Java HotSpot(TM) 64位Server VM 1.8.0_92。

我用这些开关启动了unix:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80

然后我试着在没有命令行开关的情况下运行jconsole.exe,它不能识别由Nuix启动的JVM。我尝试使用jdb.exe -attach <Port>创建远程连接,但应用程序失败,出现此异常。

java.io.IOException: shmemBase_attach failed: The system cannot find the file specified

我确认在80端口上没有其他监听,并且没有被阻塞。

连接调试器的正确方法是什么?

作为一个侧面问题,如何可能为Windows .exe使用jar ?我以前从未见过这种架构,我也不相信IKVM。根据进程资源管理器,使用。NET,而不使用j#,因为应用程序是非托管的。

为了附加调试器,我做了以下操作。注意,由于无法更改防火墙配置,我使用了端口80。我意识到端口8000是传统的Java调试端口。

jconsole.exe

  1. 使用此开关启动linux

    -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80
    
  2. 获取nuix_app.exe的Windows进程号

  3. 运行jconsole.exe <PID> .

jdb.exe

  1. 使用此开关启动linux

    -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80
    
  2. 使用这些开关运行jdbc .exe:

    jdb -connect com.sun.jdi.SocketAttach:port=80
    
  3. 输入run使unix退出挂起模式

Eclipse火星

  1. 使用此开关启动linux

    -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=80
    
  2. 转到运行->调试配置…-> Remote Java Application.

  3. 配置
    Connection Type = Standard (Socket Attach)
    Host = localhost
    Port = 80
    
  4. 点击Debug

  5. 进入窗口->透视图->打开透视图-> Java。

Java任务控制(jmc.exe)

  1. 使用这些开关启动linux

    -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=80
    -Dcom.sun.management.jmxremote.local.only=false 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Djava.rmi.server.hostname=127.0.0.1
    
  2. 单击Create a new custom JVM Connection.

  3. 配置选项
    Host = 127.0.0.1
    Port = 80
    
  4. 点击测试连接按钮

VisualVM 1.4

  1. 使用这些开关启动linux

    -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=80
    -Dcom.sun.management.jmxremote.local.only=false 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Djava.rmi.server.hostname=127.0.0.1
    
  2. 在应用程序树中,右键单击本地,然后单击添加JMX连接....

  3. 选择localhost:80,单击"确定"。

  4. 在应用程序树中双击localhost:80 (pid:[进程ID])


从Windows进程运行JVM

基于JavaAccessBridge-64.dll的存在,我相信linux使用的是JavaAccessBridge

相关内容

最新更新