0

I need to export a lwjgl 2 App from eclipse. I export the jar file (TS.jar), add the jars and natives to it with jarsplice (TS_FULL.jar), run the app from cmd with:

java TS_FULL.jar

and it says it cant find main class, strange given that at export time I checked "create manifest" and selected the correct main class, which is Main.Main. So I specify the main class with:

java -cp TS_FULL.jar Main.Main

This time it finds the main class but throws a:

UnsatisfiedLinkError: no lwjgl in java.library.path

I dont understand why this happens since I correctly added both jars and natives in the eclipse project setup, see attachement.

Any help would be appreciated, thanks. Eclipse project

JarSplice view

CMD view

EDIT: Ok so Im too tired to look into it right now, but apparently if I run

java -jar TS_FULL.jar

it runs fine. If I use

 java TS_FULL.jar

it wont find the main class. If I run

 java -cp TS_FULL.jar Main.Main

it will find the main class but wont find the lwjgl.dll. I dont know why, I will look into it. Anyway Im happy I solved it, partially at least. At least it works now.

StefanoN
  • 147
  • 1
  • 7
  • If I understand you correctly, it works in Eclipse, but not if you package the DLLs into a single JAR and run it from the command line, right? That's not possible. Either don't package the DLLs into the JAR or your Java application has to extract the DLLs itself and then load them dynamically. – howlger May 02 '20 at 13:15
  • @howlger that is exactly what is happening. I suspect something is up with my code and not the libraries, because I tried to to export a simple blank screen lwjgl app and it all worked. I think Ill try to remove parts of the code one by one and see if it makes a difference. – StefanoN May 02 '20 at 16:20
  • I guess _The Fat Jar Creator_ wraps your main class with [something like that](https://stackoverflow.com/a/49500154/6505250) calling `System.load(...)` with the absolut path for each extracted DLL, but then `System.load("lwigl")` is called for the already loaded DLL causing this issue. – howlger May 02 '20 at 17:08

0 Answers0