How can I debug applications under Java Web Start (JNLP)?

Viewed 62247

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.

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

9 Answers

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.

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:

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

You can run your JNLP with debugging enabled:

javaws -Xnosplash -J-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5009 <application>.jnlp

Output: Listening for transport dt_socket at address: 5009

Attach to this with your favorite IDE, I use IntelliJ IDEA Run>Attach to process

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?

Related