In Eclipse, my exported executable jar doesn't do anything ! (LWJGL)

Orteil picture Orteil · Mar 7, 2012 · Viewed 9.7k times · Source

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 ?

Answer

SimonSez picture SimonSez · Mar 7, 2012

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!