Tuesday, February 5, 2013

Java Web Start: debugging

Have you ever been in a need to debug JWS application?

One way to do the trick is to adapt environment variable: JAVAWS_VM_ARGS

As I'm running linux and need this in my daily work, I added following to my .bashrc file:
export JAVAWS_VM_ARGS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9010,server=y,suspend=n -XX:MaxPermSize=128m"

Some notes:
  • suspend=n - this makes sence for me, as I'm not waiting for debugger to connect. To make sure I connect only once I'm interested. And app won't get stuck
  • -XX:MaxPermSize=128m - is not related to debugging but rather to memory, feel free to remove/adapt to your needs

After jws runs, I can connect from eclipse to port configured, in my case: 9010 (use the one that fits your environment) and remotely debug the app.

That's it. Easy, right?

There are however also some disadvatages of my simple solution.
Major one is that I can have only one JWS instance running at time. As there is a port conflict (same ons is in use for every one), but I can live with that.

No comments: