Hey guys, I’d like to be able to export a runnable jar from the command line rather than having to go through File->Export->Runnable Jar File->…->Finish. Can I do this with eclipse somehow?
Otherwise, is there a way to get the build script from my project and use ant to build it from the command line?
Why not writing your own Ant script from scratch? This is what I do and it has worked very well. I create a “runnable” JAR and I wrap it into a self-contained native application bundle
Thanks for the reply
What do you mean by introducing dependencies?
I have a semi-complicated setup. My game engine, rendering & network code are split into separate projects, plus separate projects for my game client, server and updater. They require some external libraries ( rhino js, poly2tri, apache commons etc) the client/renderer requires LWJGL.
I need to build 3 jars
-client
-server
-updater
and it would be great if I could just run ant files for all three (I want to make this an automated process I can run from a build server)
Maybe this is the way to go. Just feels like a complicated task to do it from scratch and make it work with my setup (above) However I’m willing to give it a shot Do you have any more information / good links on this?
Thanks
Try exporting the ant build script and looking at it to see what I mean. It includes eclipse stuff that you probably don’t need, but eclipse adds for whatever reason.
That doesn’t sound that complicated. Maybe try exporting the ant build file from eclipse just to see what an ant build script looks like, then create your own based on the one exported from eclipse, but without the eclipse dependencies?
You can look at this section of my latest article, I suggest some tools but it would be a bit harder to use in your case as you use a library with no equivalent of “automated native library loading”, you’ll have to manage the Java library path by yourself:
I use lots of third party libraries and it works for me, it should work for you too. My build is entirely automated, from the compiling to the upload of the bundles (SFTP).
Thanks both of you for the replies. I will build ant files from scratch once I get the exported one working.
I exported the ant buildfiles and it created a build.xml for each of my projects. I ran “ant” inside my client directory and it said build successful (with a bunch of warnings) but I can’t find a jar file that was built / exported. Is this right? Exporting the jar using eclipse normally takes more than 2 seconds.
C:\Storm>ant
Buildfile: C:\Storm\build.xml
build-subprojects:
init:
... (repeats of below for each included project)
build-project:
[echo] Storm: C:\[...]\build.xml
[javac] C:\Storm\build.xml:222: warning: 'includeant
runtime' was not set, defaulting to build.sysclasspath=last; set to false for re
peatable builds
build:
BUILD SUCCESSFUL
Total time: 2 seconds
I am very interested in using JNDT. I am using Launch4j at the moment but it’s really only a good windows solution. I’m going to look into this further when I have time to test mac and linux further.
You can go on using Launch4j under Windows until I implement MSI support. Please note that JNDT is under GPL. If you have no plan to put your own code under GPL, you’ll have to use another tool (for example PackR). I remind it because I don’t want you to waste your precious time with a tool that you can’t use.
Well turns out my version of eclipse ant export doesn’t even have the right commands to build the jar file in there. I guess I’m just going to end up doing it from scratch following http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html
Oh, thanks for letting me know. Unfortunately I can’t put my code under GPL.
Roland
Update: It’s a lot easier than I thought to create a custom build script following that tutorial (http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html), rather than using eclipse to do it. Thanks guys.
I made a single build.xml that builds a test project, including bundling libraries and including source projects from other files rather than having to create a separate build.xml for each project.