2

I have created a game using LWJGL and Slick2d. I tried exporting my game as a runnable JAR, but when I double click the JAR nothing happens. Is there any way to find out why it isn't working or another way to run my program outside of Eclipse? If you need any information (such as code) just ask. Heres what my eclipse workspace looks like:

Workspace Screenshot

My game class file is the startup class, and I did select it as my launch configuration. All help is appreciated, thanks.

Mike
  • 323
  • 3
  • 13
Gratin
  • 113
  • 3
  • 15
  • you want to generate an executable?http://www.youtube.com/results?search_query=eclipse+exe&oq=eclipse+exe&gs_l=youtube.3...1597.5766.0.6149.19.12.4.3.3.0.107.918.11j1.12.0...0.0...1ac.1.ViP6jCUgUtE – Anthony Raimondo Apr 10 '13 at 22:34
  • Yes that is what I want to do. I just want to make a double click icon that runs the compiled code. – Gratin Apr 10 '13 at 22:35
  • just youtube eclipse exe – Anthony Raimondo Apr 10 '13 at 22:35
  • I've tried to make a runnable jar file, but it doesn't work. I've tried youtube, and everything. – Gratin Apr 10 '13 at 22:36
  • Can you please paste the contents of `META-INF/manifest.mf`, which should reside in the jar? It needs to contain a `Main-Class: ` entry – Muel Apr 10 '13 at 22:45
  • Manifest-Version: 1.0 Class-Path: . Main-Class: javaGame.Game – Gratin Apr 10 '13 at 22:54
  • You're probably missing the dependencies. You can always run it from the command line to see. – Dave Newton Apr 10 '13 at 22:56
  • This is the error I get when I run it in the command line : http://puu.sh/2xIvF. I'm assuming it has something to do with my libraries placed in the wrong spot (lwjgl, slick 2d), or my images being placed in the wrong spot. – Gratin Apr 10 '13 at 23:02
  • That looks to just be a file name issue since you are not using quotes and the filename has spaces in it. Try renaming the file to something without spaces in it for ease of use on the command line. – Trevor Freeman Apr 10 '13 at 23:04
  • I figured that out and renamed it without spaces ran it and then got this error : http://puu.sh/2xILp – Gratin Apr 10 '13 at 23:09
  • Added a link to my answer which links to another question that talks about linking to the slick libraries with a runnable jar. The answers to that questions should help you resolve your issue. – Trevor Freeman Apr 10 '13 at 23:14
  • I have already done all of the steps in that tutorial, and it works just fine when I run it in eclipse, but not in the jar file. I have no idea why this is but the error I showed above is what i'm getting when I run the jar file. Any other Ideas are appreciated. – Gratin Apr 10 '13 at 23:25
  • You need to create a batch file then to set a java system property that contains the location of the native libraries (or specify the location of these libraries in your code). I updated my answer to include this info. – Trevor Freeman Apr 10 '13 at 23:51
  • Here is my jar file : http://puu.sh/2xKVo I don't know how to direct the manifest file to lwjgl, slick, or my natives. This is what I would like to do so I can just double click the jar. Could you help me with creating the manifest file? Right now it looks like this : http://puu.sh/2xKYe – Gratin Apr 11 '13 at 00:17
  • @increment1 I think that Eclipse may be moving around where lwjgl, and slick are supposed to be. While in eclipse, they're in a lib folder inside of a package called "jars". But in the jar they're found in the folder org – Gratin Apr 11 '13 at 00:30
  • Have you tried just putting the native libraries in the same folder as the jar (not in the jar itself), and referencing that location in your code (this was one of the suggested fixes from one of the linked tutorials). – Trevor Freeman Apr 11 '13 at 17:19

2 Answers2

2

Creating a runnable jar in eclipse should do just that, and create a runnable jar file assuming there are no missing dependencies etc.

You can test your generated jar file from the command line by invoking it manually via java -jar yourjarfile.jar. If that works correctly, then the problem is that your windows install does not have jar files associated with auto-launching java. To fix that issue you can see this answer here.

If you cannot run your jar manually, then there is a dependency or other issue and you need to look into how you are creating the jar in eclipse and what options you are using (diagnosing this problem is very project dependant).

In particular, you may want to look into this question for setting up the slick libraries, and/or this slick tutorial.

Additionally, as mentioned in this forum discussion, you may need to create a batch file to execute instead of executing the jar directly in order to set the path for the native files. You can also add code directly into your application to set the location of the native libraries (if you are bundling them with your program for distribution this would probably be the easiest method for end users), see the instructions on setting your lwjgl native library location for how to do that.

Community
  • 1
  • 1
Trevor Freeman
  • 7,112
  • 2
  • 21
  • 40
  • I can't run the jar manually, and I do not know where to start about fixing missing dependencies. If you could show me how I'd be very grateful :) – Gratin Apr 10 '13 at 23:06
  • @Gratin See my comment on your question above about running manually, the problem you were seeing is only related to the filename and not the jar, so you need to fix that and try again first. – Trevor Freeman Apr 10 '13 at 23:07
0

I found a video on youtube that worked using jarsplice : https://www.youtube.com/watch?v=K6K2d6LGvu8

Gratin
  • 113
  • 3
  • 15