Reputation: 149
i'm a little stuck. I'm doing a little game in java, it's my first time, and i'm using sprites. I finally made it blink jaja, it's not much, but hey! I'm starting. the thing is that i'm using Netbeans 7.3 Ide, and my code runs. There's no problem. The problem comes when i export it as a jar. I export it and i get no error whatsoever, and the jar is created, but, i double click it, and nothing happens. Like, at all. Noting. I run it in Netbeans, and it runs. Any help would be really apretiated. Thanks in advice!
Upvotes: 2
Views: 750
Reputation: 793
I had trouble with this too, at first.
Three things you're going to need to make it work properly:
1) The MANIFEST.MF - This is something that people don't think about much. The below code, make sure it is in the META-INF/MANIFEST.MF inside your .jar
Manifest-Version: 1.0
Class-Path: lib/lwjgl.jar lib/lwjgl_util.jar lib/jinput.jar
Main-Class: <whatever your main method is in>
2) Alongside your jar, in whatever folder it is in, make a folder called 'lib'. Inside it, put all of the lwjgl jars that you are using. If you are using anything more than lwjgl.jar, lwjgl_util.jar, and jinput.jar, add it to the Class-Path variable in your MENIFEST.MF. Also, inside the lib folder, make a folder called 'natives' and take all of the native LWJGL files and put them inside that folder. That will be important for Step 3.
3) Add the following line of code early in your main method
System.setProperty("org.lwjgl.librarypath", new File("lib/natives").getAbsolutePath());
This is a "secret switch" used to enable the native files. It's smart, and only uses the natives for the operating system that the code is being run on, so don't worry about having all of the native files in the same directory.
And there you go. Export your Jar again with all of these things and you should be able to just simply double-click on it and make it launch!
Upvotes: 2