Search code examples
javaexportlwjglslick2dunresolved-external

Exported Runnable Jar File - I know what's wrong but not how to fix


How to export to runnable java file with eclipse using slick and lwjgl (Light Weight Java Graphics Library)?

So, I have done some research into this and believe I have found the root of the problem and what needs fixing, now I need to figure out how to fix it.

I have a fairly large project that use slick and lwjgl. These are both provided as .jar files that I have added to the java build path in my IDE (Eclipse INDIGO, in case you where wondering).

My goal is to export the piece into a single runnable jar file. Eclipse gives me three options for this:

  • Extract required libraries into generated JAR
  • Package required libraries into generated JAR
  • Copy required into a sub-folder next to the generated JAR

I have been gunning for the second options and it seems the easiest to deal with logically. Anyway when I select this option I press the FINISH option (the only one available to me other than BACK and CANCEL) I get the generation progress popping up for a sec and all seem well. However, if I run the resulting file I get an Unresolved Linker Error as it cannot find lwjgl.

Seeing as both slick.jar and lwgjl.jar are inside the generated JAR when viewed with winRar, I assume that some information is being lost about the java build path when everything goes from the IDE to the runnable JAR.

My research so far seems to suggest I can point the generated JAR to the enclosed files it needs through something in the manifest.txt file but this is were I have been unable to find anything more concrete.

Can anyone please advise me where to go from here?

P.S: I have tried almost every permutation of the export option and environmental options for the build path but when I run the generated JAR it get various differing errors that still all mean "I cannot find this here external".

P.P.S: I forgot to add, eclipse itself is mentioned in the manifest file as follows:

Manifest-Version: 1.0
Rsrc-Class-Path: ./ lwjgl.jar slick.jar
Class-Path: . lwjgl.jar slick.jar
Rsrc-Main-Class: Game.Game 
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

Every bit of common sense tells me that needs to be changed as it refers to the .jars' location but again, not sure what to or where to begin.


Solution

  • You could use JarSplice, just export the jar from Eclipse, with your classes and resources (don't include any libraries at this point), then use JarSplice to add any libraries and natives (like lwjgl and slick) and make the jar runnable.