LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: michel.montenegro on July 05, 2011, 05:42:23

Title: Error creating an executable jar (Slick+lwjgl)
Post by: michel.montenegro on July 05, 2011, 05:42:23
I have added the lib, including the native library (In Project)
I use Eclipse (Last Version).


C:\Java\workspace\jogos\JMMORPG>java -jar JMMORPG_fat.jar
Quote
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.libr
ary.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at org.lwjgl.Sys$1.run(Sys.java:72)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:65)
at org.lwjgl.Sys.loadLibrary(Sys.java:81)
at org.lwjgl.Sys.<clinit>(Sys.java:9Cool
at org.lwjgl.opengl.Display.<clinit>(Display.java:132)
at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:39)
at java.security.AccessController.doPrivileged(Native Method)
at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:36)

at game.cliente.core.Game.launch(Game.java:70)
at game.cliente.LaunchGame.main(LaunchGame.java:17)

how do I fix this?

-------------------

I use executar.bat
java -Xms256m -Xmx512m -Djava.library.path="C:\\Java\\workspace\\jogos\\JMMORPG\\libs\\natives\\" -jar "C:\Java\workspace\jogos\JMMORPG\JMMORPG_fat.jar"

Error change for:

QuoteC:\Java\workspace\jogos\JMMORPG>java -Xms256m -Xmx512m -Djava.library.path="C:\\
Java\\workspace\\jogos\\JMMORPG\\libs\\natives\\" -jar "C:\Java\workspace\jogos\
JMMORPG\JMMORPG_fat.jar"
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.lwjgl.DefaultSysI
mplementation.getPointerSize()I
       at org.lwjgl.DefaultSysImplementation.getPointerSize(Native Method)
       at org.lwjgl.Sys.<clinit>(Sys.java:100)
       at org.lwjgl.opengl.Display.<clinit>(Display.java:130)
       at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:39)
       at java.security.AccessController.doPrivileged(Native Method)
       at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:36)

       at game.cliente.core.Game.launch(Game.java:70)
       at game.cliente.LaunchGame.main(LaunchGame.java:17)


Screen:
Uploaded with ImageShack.us (http://imageshack.us)
Title: Re: Error creating an executable jar (Slick+lwjgl)
Post by: jediTofu on July 05, 2011, 06:22:21
I assume that folder also includes the LWJL dll files?

As for Eclipse, it looks like you need to add the jar files to your classpath (and most likely -Djava.library.path="...blah..." also).
Read this for help:
http://www.lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_Eclipse

As for outisde of Eclipse, you definitely need to add the jar files to the class path.  I also don't think the double backslashes are necessary for when running the java command:

java -cp .;jar\lwjgl.jar;jar\lwjgl_test.jar;jar\lwjgl_util.jar;jar\jinput.jar; -Xms256m -Xmx512m -Djava.library.path="C:\Java\workspace\jogos\JMMORPG\libs\natives\" -jar "C:\Java\workspace\jogos\JMMORPG\JMMORPG_fat.jar"

*See: http://www.lwjgl.org/wiki/index.php?title=Downloading_and_Setting_Up_LWJGL
Title: Re: Error creating an executable jar (Slick+lwjgl)
Post by: michel.montenegro on July 05, 2011, 14:32:11
1. I installed the plugin in Eclipse "Fat Jar Eclipse Plug-In (http://fjep.sourceforge.net/#inst).

2. I created and ran the file "execute.bat":
Quotejava -cp .;jar\lwjgl.jar;jar\lwjgl_test.jar;jar\lwjgl_util.jar;jar\jinput.jar; -Xms256m -Xmx512m -Djava.library.path="./libs/natives/" -jar "./JMMORPG.jar""

Result: He Funcines. But when I try to run the JAR directly (Enter) does not work. Anyone know how to fix this?

In ""Fat Jar Eclipse Plug-In", have parameter "Class-Path". I leave empty, which I put into it?

I want my "JAR flie" running stand-alone. (Without prayer of a *. bat)

I need him to look for the LIB and Native within the executable jar

- Yes, it works iff for the DLLs in the root directory.
- But he does not seek the Libs and Resources within the jar.


- Work: "C:\test\"
Quote
executavel.jar
lib/*
resources/*
*.dlls (natives)

- Error: "C:\test\"  <----- It should work this way
Quoteexecutavel.jar
Title: Re: Error creating an executable jar (Slick+lwjgl)
Post by: CodeBunny on July 05, 2011, 17:22:23
DLLs cannot be used from within Archives (which a Jar file is). You need to extract them out.

There is no workaround for this; the OS cannot use files it doesn't have access to.
Title: Re: Error creating an executable jar (Slick+lwjgl)
Post by: michel.montenegro on July 05, 2011, 17:46:14
So any application (+ Slick LWJGL) that use Java Web Start (JWS) is required to download the jar + native + dir (lib and resources)?
Title: Re: Error creating an executable jar (Slick+lwjgl)
Post by: CodeBunny on July 05, 2011, 18:02:43
No. You are simply required to give the OS access to the native files, and you can be as creative about that as you want.

For example, I keep my native libraries (not just for windows, for Mac and Linux as well) contained in my jars, and then I have a class that handles extracting them to a location of the user's computer. For example, on windows I use ../AppData/(game name)/Natives/ and I place them into the created folder. Every time I run the game, I re-check to see if the file exists; if it doesn't, I simply re-extract them. Thus, I save the native files between replays, but if anything happens to them, it still works and everything is restored.

You can do something similar with Java Webstart.
Title: Re: Error creating an executable jar (Slick+lwjgl)
Post by: michel.montenegro on July 05, 2011, 19:02:15
Check it out, I did not understand how to use, if they understand me to speak, is just about carrying a native library, inside the project.

* example:
    loadDynamicLibrary("natives", "jinput-dx8.dll");
    loadDynamicLibrary("natives", "jinput-raw_64.dll");
Site: http://www.guj.com.br/prepost/243014/1256214/jni-no-glassfish

My natives librarys -> "JMMORPG/libs/natives".
as would be the way in my case?
Title: Re: Error creating an executable jar (Slick+lwjgl)
Post by: CodeBunny on July 05, 2011, 19:09:31
...what?