In Application: Build Eclipse Project to JAR

Is there a way for running an application that takes an Eclipse project and exports it as a JAR file or runnable JAR file? I’m trying to make an application that when run will export my game’s code to a JAR file and then add the JAR and its dependencies to a zip file (though the latter is not what I need help for) and update that to my website directory where then I can update my website to update my game.

If I could find how Eclipse creates the JAR file then I could mimic that in my code, how do you think I could accomplish that?

Doing that yourself might be pretty hard.

I’d recommend to start using ant (or something similar). If you use ant, then you can build either your binaries or your artifacts/jars via the appropriate ant task. You can call the ant task via ant myAntTask from command line (you need to be in the directory of the build.xml).

Eclipse allows you to auto-generate an ant build xml.

I used Eclipse to save the JAR creation as an ANT script but upon calling ant MakeJar (it was called MakeJar) it says:


C:\Users\Sam\Documents\Workspace\Zombies>ant MakeJar
Buildfile: C:\Users\Sam\Documents\Workspace\Zombies\build.xml

BUILD FAILED
Target "MakeJar" does not exist in the project "Zombies".

Total time: 0 seconds

What’s going on? It exists at the same directory as build.xml.

I fixed it! I just had to rename it to build.xml and then it worked :smiley:

EDIT: I scripted for awhile and finished making my script that will update my game for me in one click. I have learned the awesomeness of ANT. It’s a great tool :smiley:

Ant is a very flexible build tool. I use it a lot in my project. You can even sign your JARs, create JNLP files and upload them into your server with Ant. Yes the automatic update mechanism is already implemented in Java Web Start…