Showing posts with label jws. Show all posts
Showing posts with label jws. Show all posts

Monday, February 18, 2013

Java web start: running unsigned jars

Q: Did you ever need to run unsigned jar files referred from jnlp (java web start)?

There is a simple (but dangerous) way.
There might be various reasons such a bad thing (bad from the security point of view), but most probably to speed up development (as jars signing is quite time intensive process).

Depending if you have jdk/jre installed add to the file (in my case jdk installed):
$JAVA_HOME/jre/lib/security/javaws.policy
following:
grant {
    permission java.security.AllPermission;
};
Since now on you should be able to run even unsigned code started using javaws command.

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.