如何在Java Web Start (JNLP)下调试应用程序?

时间:2022-11-14 20:48:22

I know how I can debug a remote Java VM with Eclipse, but how can I do it with a Java Web Start program. I have a problem that only occurs in Java Web Start. It must be security related.

我知道如何用Eclipse调试远程Java VM,但是如何使用Java Web Start程序进行调试呢?我有一个问题只发生在Java Web Start。它必须与安全有关。

I need a solution that will work with a current Java VM like 1.6.0_12.

我需要一个解决方案,它将使用当前的Java VM(如1.6.0_12)。

8 个解决方案

#1


22  

It's quite the same like with any other Java process you want to debug remotely: You have to set up some arguments for the VM (-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=12345 ) and then connect to the given port. In Java webstart 6.0 this can be done with the -J option, in earlier version via environment variable JAVAWS_VM_ARGS. See details here.

与您想要远程调试的其他Java进程完全相同:您必须为VM设置一些参数(-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=12345),然后连接到给定端口。在Java webstart 6.0中,通过环境变量JAVAWS_VM_ARGS,可以在早期版本中使用-J选项完成。在这里看到的细节。

#2


21  

Start the JWS VM manually. This way you can provide the startup parameters to open the debug port. Here is a description, it goes like this:

手动启动JWS VM。这样,您就可以提供启动参数来打开调试端口。这是一个描述,它是这样的:

set JAVAWS_TRACE_NATIVE=1
set JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8989,server=y,suspend=n"
javaws http://server:port/descriptor.jnlp

#3


12  

As for newer versions of Java (Java 8u20+ and Java 7u70+) i experienced that parameters like -Xrunjdwp cannot be passed directly nor using JAVAWS_VM_ARGS. Message Rejecting attempt to specify insecure property: -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 started to show up in console output.

对于新版本的Java (Java 8u20+和Java 7u70+),我体验过像-Xrunjdwp这样的参数不能直接传递,也不能使用JAVAWS_VM_ARGS。消息拒绝尝试指定不安全属性:-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000开始在控制台输出中显示。

The only solution that worked for me was to pass those arguments into JAVA_TOOL_OPTIONS system variable.

对我来说唯一有效的解决方案是将这些参数传递到JAVA_TOOL_OPTIONS系统变量中。

#4


9  

You can also provide the debug parameter to the javaws executable using the -J option

您还可以使用-J选项向javaws可执行文件提供调试参数。

Example:

例子:

javaws.exe -J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 http://server:port/descriptor.jnlp

#5


2  

You will need to do the following:

你需要做以下工作:

  1. Enable the Java logs and tracing in the Java Control Panel > Advanced. 如何在Java Web Start (JNLP)下调试应用程序?

    在Java控制面板>中启用Java日志和跟踪。

  2. Enable parameters for debugging Java (optional but useful i.e. problems with tls/ssl handshake as close_notify or handshake_failure) & launching the JNLP, there are two ways you can do it:

    启用调试Java的参数(可选但有用的,例如使用tls/ssl握手的问题,如关闭通知或handshake_failure) &启动JNLP,有两种方法可以做到:

    2.a. Download the JNLP file and execute it from command line (the SET command is not required in this particular case).

    2.。下载JNLP文件并从命令行执行它(在这个特殊情况下不需要设置命令)。

    set JAVA_TOOL_OPTIONS=-Djavax.net.debug=all
    javaws -wait jnlp.jnlp
    

    2.b. Add arguments (i.e. -Djavax.net.debug=all) for the JVM in the Java Control Panel > Java > View (this is not required in this particular), and launch the JNLP file from browser:

    2. b。在Java控制面板> Java >视图中,为JVM添加参数(即-Djavax.net.debug=all),并从浏览器启动JNLP文件:

    如何在Java Web Start (JNLP)下调试应用程序?

  3. The logs and traces are located in the log directory from the Java Deployment Home from where I paste these locations:

    日志和跟踪位于从Java部署返回的日志目录中,从这里粘贴这些位置:

    a. Windows XP: %HOME%\Application Data\Sun\Java\Deployment

    Windows XP: %HOME%\应用程序数据\Sun\Java\部署。

    b. Windows 7/Vista: %APPDATA%\..\LocalLow\Sun\Java\Deployment

    Windows 7 b。/ Vista:% APPDATA % \ . . \ LocalLow \ \ Java \部署

    c. Linux/Solaris: %HOME%/.java/deployment

    c。Linux / Solaris:% % / . java /部署

With javax.net.debug=all you will see the handshake if the jar inside the jnlp is loaded from an https connection. This kind of problems are hard to debug.

使用javax.net.debug=所有您将看到的握手,如果jnlp中的jar是从https连接加载的。这种问题很难调试。

...
%% No cached client session
*** ClientHello, TLSv1.2
...
***
... 
Java Web Start Main Thread, received EOFException: error
Java Web Start Main Thread, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
Java Web Start Main Thread, SEND TLSv1.2 ALERT:  fatal, description = handshake_failure
Java Web Start Main Thread, WRITE: TLSv1.2 Alert, length = 2
Java Web Start Main Thread, called closeSocket()
#### Java Web Start Error:

#6


1  

Have you tried printing a debug log? That is a useful thing to have at any rate, and might help in this case.

您试过打印调试日志吗?无论如何,这是一件很有用的事情,在这种情况下可能会有所帮助。

If you want real debugging, see e.g. here: How can I debug under WebStart?

如果您想要真正的调试,请参见这里:如何在WebStart下进行调试?

#7


1  

To debug a Web Start application in Linux, create a shell script ~/bin/javaws-debug.sh with the javaws invocation in debug mode as described above:

要调试Linux中的Web Start应用程序,请创建一个shell脚本~/bin/javaws-debug。按照上面描述的调试模式中的javaws调用:

~/bin/javaws-debug.sh:

~ / bin / javaws-debug.sh:

#!/bin/sh
export JAVAWS_TRACE_NATIVE=1
export JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE 
  -Xrunjdwp:transport=dt_socket,address=8989,server=y,suspend=n"
javaws "$@"

Then, in your browser, choose that script as the application to invoke on jnlp files.

然后,在浏览器中,选择该脚本作为调用jnlp文件的应用程序。

For example, in Firefox, go to Edit→Preferences→Applications, Content Type: Java Web Start, and choose "Use Other" in Action and pick the script from the "Select Helper Application" dialog. In Chrome, you need to alter Linux system settings. In KDE, go to System Settings→File Associations, Known Types: application:x-java-jnlp-file, add a new Application, pick ~/bin/javaws-debug.sh from the "Choose Application for application/x-java-jnlp-file" dialog.

例如,在Firefox,去编辑→设置→应用程序,内容类型:Java Web Start,选择“使用其他”行动和选择的脚本“选择辅助应用程序”对话框。在Chrome中,你需要改变Linux系统的设置。在KDE中,进入系统设置→文件关联,已知类型:应用范围:x-java-jnlp-file,添加一个新的应用程序,选择~ / bin / javaws-debug。来自“选择应用程序/x-java-jnlp-file”对话框。

Once your browser is configured, Java Web Start application will start using your wrapper, which will enable debugger to connect on port 8989.

一旦您的浏览器被配置好,Java Web Start应用程序将开始使用您的包装器,它将使调试器能够在8989端口上连接。

#8


1  

With Java 8 and Windows 10, open command prompt (cmd.exe) and type this:

使用Java 8和windows10,打开命令提示符(cmd.exe)并键入:

set JAVAWS_TRACE_NATIVE=1
set JAVA_TOOL_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
javaws java-app.jnlp

#1


22  

It's quite the same like with any other Java process you want to debug remotely: You have to set up some arguments for the VM (-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=12345 ) and then connect to the given port. In Java webstart 6.0 this can be done with the -J option, in earlier version via environment variable JAVAWS_VM_ARGS. See details here.

与您想要远程调试的其他Java进程完全相同:您必须为VM设置一些参数(-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=12345),然后连接到给定端口。在Java webstart 6.0中,通过环境变量JAVAWS_VM_ARGS,可以在早期版本中使用-J选项完成。在这里看到的细节。

#2


21  

Start the JWS VM manually. This way you can provide the startup parameters to open the debug port. Here is a description, it goes like this:

手动启动JWS VM。这样,您就可以提供启动参数来打开调试端口。这是一个描述,它是这样的:

set JAVAWS_TRACE_NATIVE=1
set JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8989,server=y,suspend=n"
javaws http://server:port/descriptor.jnlp

#3


12  

As for newer versions of Java (Java 8u20+ and Java 7u70+) i experienced that parameters like -Xrunjdwp cannot be passed directly nor using JAVAWS_VM_ARGS. Message Rejecting attempt to specify insecure property: -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 started to show up in console output.

对于新版本的Java (Java 8u20+和Java 7u70+),我体验过像-Xrunjdwp这样的参数不能直接传递,也不能使用JAVAWS_VM_ARGS。消息拒绝尝试指定不安全属性:-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000开始在控制台输出中显示。

The only solution that worked for me was to pass those arguments into JAVA_TOOL_OPTIONS system variable.

对我来说唯一有效的解决方案是将这些参数传递到JAVA_TOOL_OPTIONS系统变量中。

#4


9  

You can also provide the debug parameter to the javaws executable using the -J option

您还可以使用-J选项向javaws可执行文件提供调试参数。

Example:

例子:

javaws.exe -J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 http://server:port/descriptor.jnlp

#5


2  

You will need to do the following:

你需要做以下工作:

  1. Enable the Java logs and tracing in the Java Control Panel > Advanced. 如何在Java Web Start (JNLP)下调试应用程序?

    在Java控制面板>中启用Java日志和跟踪。

  2. Enable parameters for debugging Java (optional but useful i.e. problems with tls/ssl handshake as close_notify or handshake_failure) & launching the JNLP, there are two ways you can do it:

    启用调试Java的参数(可选但有用的,例如使用tls/ssl握手的问题,如关闭通知或handshake_failure) &启动JNLP,有两种方法可以做到:

    2.a. Download the JNLP file and execute it from command line (the SET command is not required in this particular case).

    2.。下载JNLP文件并从命令行执行它(在这个特殊情况下不需要设置命令)。

    set JAVA_TOOL_OPTIONS=-Djavax.net.debug=all
    javaws -wait jnlp.jnlp
    

    2.b. Add arguments (i.e. -Djavax.net.debug=all) for the JVM in the Java Control Panel > Java > View (this is not required in this particular), and launch the JNLP file from browser:

    2. b。在Java控制面板> Java >视图中,为JVM添加参数(即-Djavax.net.debug=all),并从浏览器启动JNLP文件:

    如何在Java Web Start (JNLP)下调试应用程序?

  3. The logs and traces are located in the log directory from the Java Deployment Home from where I paste these locations:

    日志和跟踪位于从Java部署返回的日志目录中,从这里粘贴这些位置:

    a. Windows XP: %HOME%\Application Data\Sun\Java\Deployment

    Windows XP: %HOME%\应用程序数据\Sun\Java\部署。

    b. Windows 7/Vista: %APPDATA%\..\LocalLow\Sun\Java\Deployment

    Windows 7 b。/ Vista:% APPDATA % \ . . \ LocalLow \ \ Java \部署

    c. Linux/Solaris: %HOME%/.java/deployment

    c。Linux / Solaris:% % / . java /部署

With javax.net.debug=all you will see the handshake if the jar inside the jnlp is loaded from an https connection. This kind of problems are hard to debug.

使用javax.net.debug=所有您将看到的握手,如果jnlp中的jar是从https连接加载的。这种问题很难调试。

...
%% No cached client session
*** ClientHello, TLSv1.2
...
***
... 
Java Web Start Main Thread, received EOFException: error
Java Web Start Main Thread, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
Java Web Start Main Thread, SEND TLSv1.2 ALERT:  fatal, description = handshake_failure
Java Web Start Main Thread, WRITE: TLSv1.2 Alert, length = 2
Java Web Start Main Thread, called closeSocket()
#### Java Web Start Error:

#6


1  

Have you tried printing a debug log? That is a useful thing to have at any rate, and might help in this case.

您试过打印调试日志吗?无论如何,这是一件很有用的事情,在这种情况下可能会有所帮助。

If you want real debugging, see e.g. here: How can I debug under WebStart?

如果您想要真正的调试,请参见这里:如何在WebStart下进行调试?

#7


1  

To debug a Web Start application in Linux, create a shell script ~/bin/javaws-debug.sh with the javaws invocation in debug mode as described above:

要调试Linux中的Web Start应用程序,请创建一个shell脚本~/bin/javaws-debug。按照上面描述的调试模式中的javaws调用:

~/bin/javaws-debug.sh:

~ / bin / javaws-debug.sh:

#!/bin/sh
export JAVAWS_TRACE_NATIVE=1
export JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE 
  -Xrunjdwp:transport=dt_socket,address=8989,server=y,suspend=n"
javaws "$@"

Then, in your browser, choose that script as the application to invoke on jnlp files.

然后,在浏览器中,选择该脚本作为调用jnlp文件的应用程序。

For example, in Firefox, go to Edit→Preferences→Applications, Content Type: Java Web Start, and choose "Use Other" in Action and pick the script from the "Select Helper Application" dialog. In Chrome, you need to alter Linux system settings. In KDE, go to System Settings→File Associations, Known Types: application:x-java-jnlp-file, add a new Application, pick ~/bin/javaws-debug.sh from the "Choose Application for application/x-java-jnlp-file" dialog.

例如,在Firefox,去编辑→设置→应用程序,内容类型:Java Web Start,选择“使用其他”行动和选择的脚本“选择辅助应用程序”对话框。在Chrome中,你需要改变Linux系统的设置。在KDE中,进入系统设置→文件关联,已知类型:应用范围:x-java-jnlp-file,添加一个新的应用程序,选择~ / bin / javaws-debug。来自“选择应用程序/x-java-jnlp-file”对话框。

Once your browser is configured, Java Web Start application will start using your wrapper, which will enable debugger to connect on port 8989.

一旦您的浏览器被配置好,Java Web Start应用程序将开始使用您的包装器,它将使调试器能够在8989端口上连接。

#8


1  

With Java 8 and Windows 10, open command prompt (cmd.exe) and type this:

使用Java 8和windows10,打开命令提示符(cmd.exe)并键入:

set JAVAWS_TRACE_NATIVE=1
set JAVA_TOOL_OPTIONS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
javaws java-app.jnlp