EXE Creation (with LWJGL)

Hey all,

I’m wondering how you all go about creating EXEs from your JARs, especially ones that need to include natives like LWJGL. I know there are some PC tools out there but I’d prefer to be able to build it from Mac OS X (which is what I dev on).

Similarly, does anyone have example SH and BAT files for executing a LWJGL jar? That would at least do the trick for now.

I used;

java -Djava.library.path=[path to native dlls] -cp lwjgl.jar;lwjgl_util.jar;jinput.jar;game.jar; Game

Here is an example that uses sh/bat files. I created it a while back so it uses a really old version of lwjgl (not sure it will still work on modern computers) but it should still be a good example on how to use sh/bat files with LWJGL.

There is this ‘trick’ to convert a JAR into an exe.

First you create your foo.jar, then you create a C app, like so:


#include <process.h> 
int main(void)
{
   execlp("java.exe", 
      "java.exe", 
      "-cp", 
      "foo.exe", // not for.jar
      "my.perfect.Game", 
      NULL); 

   return 0; 
}

and compile it. You end up with foo.exe. Now append foo.jar to foo.exe and launch it!

Obviously your OS cannot find any libraries inside your exe, so you’d have to manually extract those files from the archive, which is trivial.

Thanks everyone. That should do the trick. :slight_smile:

If you want something simpler and that works on Mac, try Launch4j.