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
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!