Orteil
Orteil

Reputation: 441

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

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 ?

Upvotes: 4

Views: 9814

Answers (3)

Nick Clark
Nick Clark

Reputation: 1446

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.

Upvotes: 0

Purple
Purple

Reputation: 31

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

Upvotes: 3

SimonSez
SimonSez

Reputation: 7769

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!

Upvotes: 5

Related Questions