Friday, October 17, 2008

Debugging JWS with Eclipse

After nearly 10 years, I spent considerable amount of time working on java desktop application recently. Looking at Java Web Start forums and FAQ it appears still users have issues with setting up Eclipse Remote Debugging with Java Web Start. This can be easily achieved by following three simple steps:

1. Debug Java Web Start applications locally before deploying them on your web server. i.e use javaws <<fileName>> and not javaws <<url>> and set your codebase in jnlp file to local libraries (like codebase="file:///c:/jwstest").

2. set JAVAWS_VM_ARGS environment variable to right value.
Example set JAVAWS_VM_ARGS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8199

Make sure you don't use "-classic".

3. Start Eclipse remote debugging targeting localhost and port set in JAVAWS_VM_ARGS (8199 in this example).

One thing that comes handy is collecting your logs from application in a log file while using Java Web Start.Tracing features for Java Web Start comes handy in this case.