Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

java - Can't start .jar file (using LWJGL)

Good day!

I created jar file (using Netbeans) and i can't start it. This project uses lwjgl libraries. Inside my IDE it works well.

I use next command:

java -jar LWJGL_TimerExample.jar 

Answer is:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:82)
at org.lwjgl.Sys.<clinit>(Sys.java:99)
at org.lwjgl.opengl.Display.<clinit>(Display.java:130)
at Sourse.TimerExample.start(TimerExample.java:32)
at lwjgl_timerexample.Main.main(Main.java:21)

Other projects (without this libraries) work fine. How can i solve this error?

My Manifest is:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Created-By: 1.6.0_26-b03-384-10M3425 (Apple Inc.)
Main-Class: lwjgl_timerexample.Main
Class-Path: lib/jinput.jar lib/lwjgl.jar lib/lwjgl_util.jar
X-COMMENT: Main-Class will be added automatically by build
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It's not going to work the way you're trying to currently do it, since you need to have the native files along side the jar and point to them via the '-Djava.library.path' parameter.

If you just want a single jar and want to avoid the hassle of the command line and native files use the JarSplice tool. JarSplice is easy to use and will automatically handle the native file stuff for you.

1) Simply export your project (class and resources) to a jar (easier just to do it through your IDE).

2) Then run JarSplice, add all the jars you need to the jars tab (your app jar, lwjgl.jar, and any other external jar you're using).

3)Then on the natives tab add all the natives files (windows *.dll, linux *.so, mac *.dylib & *.jnilib).

4)On the class tab add your main class. Then create your jar.

You can then run this jar just by double clicking it (or if you wish via command line using 'java -jar yourapp.jar').


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...