Wednesday, January 28, 2004

Running Java Utilities

Yesterday afternoon Bob and I were bemoaning the difficulty of using java for little utilities. Its not that they are hard to write, rather that they are hard to run. If you want to package some small functionality for your Mom you don't want to have to tell her to open a command prompt and type 'java -jar utility.jar'. This means you need to always build a shell script (bat file) to help run the utility. That's a pain.


The installer for the JRE tries to make running java programs easier by mapping .jar to javaw.exe. But this only helps if your jar contains a Swing or AWT app. If your jar contains a console utility you get no feedback at all.


What I've done to make life easier for myself is to make a new file mapping to an extension called .jex.

(path to java)\java.exe -jar "%1"

I then just rename my utility jars to .jex instead of .jar. This allows me to double click on or type the name of any .jex file and have it run properly,


There's probably a better way to do this. If anyone knows (besides switching OSs) please let me know. Given the ubiquity of Java in the world I would fiqure we aren't the only folks to have been bothered by this.


Post a Comment
 
The Out Campaign: Scarlet Letter of Atheism