4

Java beginner here.

I made a small java app in Eclipse (on Windows), using the LWJGL lib and Slick. Then when I export is as an executable .jar file, and run the resulting .jar, it doesn't do anything. No errors, no nothing - just doesn't seem to run. I am following this tutorial : http://www.cs.bsu.edu/homepages/pvg/misc/slick_eclipse_tutorial.php

Here's what my manifest.mf file looks like :

Manifest-Version: 1.0
Main-Class: SimpleTest
Class-Path: lib/lwjgl.jar lib/slick.jar

Apps that don't use LWJGL export just fine. What am I doing wrong ?

I tried using JarSplice, which didn't work, though I might be misusing it. Any pointers ?

Orteil
  • 439
  • 6
  • 16
  • did you add the jar to the build path? – Th0rndike Mar 07 '12 at 09:00
  • 1
    How are you running it? You run something like `java -cp ".:lwjgl.jar" -jar game.jar` and it terminates with no output? Did you tell Eclipse to generate the manfiest file and point it to your main class? – Daniel Lubarov Mar 07 '12 at 09:26
  • @Daniel - I'm running the resulting .jar simply by double-clicking on it in Windows. I'm really not familiar with using the command line. Would that have a lower failure rate when dealing with tricky subjects such as this one ? And yes, I do refer to the main class in the manifest. – Orteil Mar 14 '12 at 02:56

3 Answers3

5

My best bet is that you missed to reference your Main-class in the manifest-file.

Have a look at this it shows how to set up your manifest-file correctly.

Have Fun!

EDIT:

Manifest-Version: 1.0 
Main-Class: SimpleTest 
Class-Path: lib/lwjgl.jar lib/slick.jar  
<-- new line without any content -->

EDIT 2:

OK, I was able to reproduce this behavior. As I tried to run the exported jar via console I've got the following exception:

Exception in thread "main" java.lang.reflect.InvocationTargetException
   ...
Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
   ... 
    ... 5 more

After doing some researches I found out that it is hardly possible to package native dll's to an executable jar.
To clarify, I've found three options:

  1. Just normally export your jar as Runnable JAR within Eclipse and after that place it in a folder containing the native dll's (checked this, worked for my setup with your tutorial)
  2. At execution extract your dll's in a temporary directory as mentioned here
  3. Or use the One-Jar project which lets you create runnable jars with native libraries

Hope this solved your problem. Cheers!

Community
  • 1
  • 1
SimonSez
  • 7,399
  • 1
  • 30
  • 35
  • Doesn't seem to be the problem. My manifest looks like : `Manifest-Version: 1.0 Main-Class: SimpleTest Class-Path: lib/lwjgl.jar lib/slick.jar` Am I still missing something ? – Orteil Mar 14 '12 at 02:52
  • Those `MANIFEST` files are very fragile/sensible. Could you make sure that there is a return/new line at the end of your file (see my edit). – SimonSez Mar 14 '12 at 08:26
  • Yep, tried that, wasn't the problem either I think. I'm giving up Java anyway, XNA looks more accessible for someone like me who doesn't want to mess around with build paths and manifest files. Thanks though ! – Orteil Mar 14 '12 at 20:13
  • 1
    Sad to hear! Nevertheless I'll have a deeper look. If I can work something out I'll let you know! Cheers. – SimonSez Mar 14 '12 at 23:28
3

I'm having similar issues with eclipse and Slick, and here's what I've found. (pulled from the LWJGL wiki)

I keep getting an java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

This is because the native part is not setup correctly. Add a -Djava.library.path=path/to/dir to the commandline or as an VM option in your IDE so that lwjgl is able to find the folder containing the native files.

In short, the exported jar is missing the proper natives

Now, when compiling to a runnable jar, I'm assuming you want a double-click-to-launch style of application, so that's not quite a possibility.

you could set the java.library.path after launch with System.setProperty, or put the required natives in default library path.

I haven't quite found on the best solution myself, but I hope this helped

Community
  • 1
  • 1
Purple
  • 31
  • 1
0

Try using Jar Splice http://ninjacave.com/jarsplice All you will need to do is give it all your .jar files (main and libraries) and all of your DLLs. It can create a .jar that works. It can also make an executable (.exe), as well as the Linux and Mac equivalencies.

Nick Clark
  • 1,414
  • 2
  • 16
  • 24