Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remote debugging java web start under JVM 1.8

I have a Java Web Start application, which I used to start through a shortcut:

"C:\Program Files\Java\jdk1.7.0_67\bin\javaws.exe" -J-Dfile.encoding=UTF-8 -J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=8200" http://xxx/yyy/zzz.jnlp

But after installing JDK 1.8 it all stopped working, my javaws don't see any of additional X||D params. I tried this way:

setenv JAVAWS_VM_ARGS "-Dfile.encoding=UTF-8 -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=n,suspend=y,address=8200"
"C:\Program Files\Java\jdk1.8.0_25\bin\javaws.exe" http://pont/dms/InstallDMS_debug.jnlp

But no use.

The only solution I found is to set params using Java control panel, adding them directly to JVM.

Control Panel > Java > Java (tab) > View (button) > Runtime parameters (field)

How can I set params for 1.8 good old way?

P.S. JDK 1.6 x32 still works well with shortcuts. x64 1.7 starts but references to 1.8 libs, so I think all JDK x64 are in collusion.

like image 230
Ivan Tamashevich Avatar asked Oct 31 '14 06:10

Ivan Tamashevich


People also ask

How do I start JVM in debug mode?

Enable JVM DebuggingClick Java > JVM Settings tab. Under Debug Java Settings, select the Enable Debug checkbox. Provide JVM options as necessary by clicking the New button. If you substitute suspend=y, the JVM starts in suspended mode and stays suspended until a debugger attaches to it.

What is remote JVM debug?

Remote Java Debugging is the process of debugging a Java program or application running on another machine or a server environment.

How do I run remote debugging?

Set up the remote debugger. On the remote computer, find and start the Remote Debugger from the Start menu. If you don't have administrative permissions on the remote computer, right-click the Remote Debugger app and select Run as administrator. Otherwise, just start it normally.

How do I start debugging in Java?

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead.


2 Answers

Blatantly stealing Saeid Nourian's comment-answer:

Add -Xdebug -agentlib:jdwp=transport=dt_socket,address=9999,server=y,suspend=y to the arguments in the Java Control Panel.

like image 63
Sbodd Avatar answered Sep 27 '22 18:09

Sbodd


Starting from the (approximately) version 1.7.0_022 java web start launcher significantly alters list of supplied JVM-arguments and properties by treating vast of them as unsecured.

You can set the JAVA_TOOL_OPTIONS environment variable with described above debug switches instead of java control panel parameters before running JNLP file. (See http://www.oracle.com/technetwork/java/javase/envvars-138887.html#gbmsy and http://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html#tooloptions). This is the correction of the previous Ivan' answer.

For example, you can try the following batch-file which was tested for JDK 1.8.0_60:

setlocal

set JAVAWS_TRACE_NATIVE=1
set JAVA_TOOL_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8002,server=y,suspend=n %JAVA_TOOL_OPTIONS%

set JAVA_HOME_64=c:\Java\64\jdk1.8
set JAVA_HOME=%JAVA_HOME_64%
set JDK_JRE_HOME=%JAVA_HOME%\jre
set JRE_HOME=%JDK_JRE_HOME%

set ONLINE_JNLP_URL=http://pont/dms/InstallDMS_debug.jnlp

"%JRE_HOME%\bin\javaws" %ONLINE_JNLP_URL%

endlocal

Additionally, I would like to notice that for remote debugging of Java WS-applications it is essential to run JDK's JRE but not public JRE, otherwise you can observe that JVM terminates before executing your main class.

like image 23
roof Avatar answered Sep 27 '22 20:09

roof