Sunday, August 3, 2008

Eclipe Ganymede - Executable Jars

Eclipse Ganymede (3.3) has some cool new features. One that I just discovered today is really cool and saved me a bunch of time: Export to Executable Jars.

Here is how it works: make a Java program with a runnable class. Build up your build path and get a clean compile. Execute your program locally with the normal "Run as..." tools. This isn't anything new. The new thing is the ability to export to a single, executable jar file.

Here is how:

  • Right click on project
  • Choose "Export"
  • Choose "Runnable JAR file"
  • Follow the prompts to pick the runner and the destination

When the export is finished, you can execute this single jar as: java -jar [jarfile].jar

Use Case:
Here is how I use this: I am developing a database app that needs to suck in data from a MySQL database stored on a remote system. I can VPN in over my DSL line, and it works great for testing. I usually add a "limit 100" or some reasonable number to large select statements so I can debug quickly. Then, when I'm ready to run the program "for real" on the large dataset (this one contains over 100,000 entries of large XML fields, I don't really want to run this over my DSL line. Many reasons for this:
  • Tie up my Powerbook from other cool things
  • Saturate my DSL line
  • Tie up records in my database waiting for data buffers to flush in between locks
In the past, I manually concocted a UNIX tar file with all of the dependent jars, classes, etc. and used SSH's "scp" feature to move it onto the UNIX host. It wasn't too bad - but it was a pain when there were a lot of jars. One project I have uses over 50 different JAR files! Debugging was painful.

Now, I can use this feature to dump out one JAR file and execute it directly on the remote system!

FEATURE REQUEST: Use this to target a remote host, and use RSYNC to put the JAR file on the remote host and SSH to execute it.... that would be killer!

Sunday, February 17, 2008

Mac OSX Tricks

Mac OSX Tricks
I've learned some cool Mac OSX Tricks along the way, that I'm sure to forget before too long. I'll try to add them here and maybe build up a nice list of cool tricks and necessary fixes.
  • I like old green-screen terminal, so set Terminal's preference to default to Homebrew
  • JAVA_HOME wasn't set: added

    export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home

    To /etc/bashrc. After new login (or . /etc/bashrc) echo $JAVA_HOME works. I found this necessary for some ant scripts.