I have a project in eclipse, runs perfectly fine in the ide when I click run, but I need to export it into a runnable jar file which also works fine. But when I try to run it it throws an exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no j3dcore-ogl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1856)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at javax.media.j3d.NativePipeline$1.run(NativePipeline.java:231)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.NativePipeline.loadLibrary(NativePipeline.java:200)
at javax.media.j3d.NativePipeline.loadLibraries(NativePipeline.java:157)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:987)
at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:299)
at javax.media.j3d.GraphicsConfigTemplate3D.getBestConfiguration(GraphicsConfigTemplate3D.java:321)
at java.awt.GraphicsDevice.getBestConfiguration(GraphicsDevice.java:207)
at com.sun.j3d.exp.swing.JCanvas3D.<init>(JCanvas3D.java:228)
at com.sun.j3d.exp.swing.JCanvas3D.<init>(JCanvas3D.java:178)
at mainproject.MainPanel.<init>(MainPanel.java:72)
at mainproject.MainWindow.<init>(MainWindow.java:42)
at mainproject.MainWindow.main(MainWindow.java:23)
I have been googling it for 2 days now, tons of results, none helpful.
I export it by going to file->export->java->Runnable jar file->i bubble extract required libraries into generated jar, choose the correct configuration, save the file in a specified folder, then it saves just fine. Or at least so I think. The java.library.path goes to the jre lib folder, but when i run it in eclipse it goes to the .so for j3d, i tried changing it using System.setProperty but to no success. I have a feeling that is the problem, but when I tried to fix it nothing happened. I'm using the most up to date java3d library (1.5.2 I believe).
Any suggestions?
If I set
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jni
it works.
Related
I tried downloading the open DMX java wrapped form here. I'm using Eclipse as IDE. When I run the example I got the java.lang.UnsatisfiedLinkError openDMX.
So I googled the hell out of it and I found out that I had to define the build path of the dll file (from what I found this had to do with the driver for the usb device?)
I tried the following:
Definde the path in run configurations->vm arguments and then -Djava.library.path=dll
as was included in the readme. This gave the same exception
Then I found that I could define the build path. Right clicked the main folder in the file browser in eclipse.
Then properties->libraries->JRE system libraries->native library location
I browsed in the workspace for de dll folder and set the opendmx_example/dll as the native library location
Stil: Exception in thread "main" java.lang.UnsatisfiedLinkError: no opendmx in java.library.path
Does somebody experience the same trouble or is it something that I'm doing wrong
Any help is much appreciated!
I need to create a runnable jar in Windows with Eclipse and start it with Linux
I'm getting an unsatisfiedLinkError while loading OpenCv. I have edited the correct library path for a Linux computer in Eclipse and finally created a runnable jar. When I start the *.jar file in linux and get the following error.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no
opencv_java2411 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1889)
at java.lang.Runtime.loadLibrary0(Runtime.java:900)
at java.lang.System.loadLibrary(System.java:1087)
Basically i have two question.
1. How can i get the loaded library path at runtime?
2. Is it possible that the chosen way is not the right way to handle the problem?
Thanks
One important this to keep in mind for loading linux libraries with System.loadLibrary, omit the lib prefix in the library name, for instance, if the library name is libxyz.so, your call would be:
System.loadLibrary("xyz");
Set the path of OpenCV in the variable LD_LIBRARY_PATH. You can do it in the shell where you run the "jar". Use export command.
I wrote a program to communicate with an arduino using the RXTXcomm.jar. It works in eclipse because I "Added External Jars" in the edit class path option.
I got the tutorial off this website: http://www.drdobbs.com/jvm/control-an-arduino-from-java/240163864. I originally tried running the command on that website to get the RXTXcomm.jar to work without having to use the eclipse work around but I couldnt get it to work (after much time and research). However, now I want to make an .exe out of my program. I used Launch4J to make an .exe and it works but, like before the eclipse work around, the serial communication aspect doesn't work.
I have thought of two fixes, I do not know the plausibility of either however:
1) Some how export my java gui to a jar file that contains the RXTXcomm.jar that was added when using eclipse work around
2) Write a script that I run once to set the computer up that will allow me to use the RXTXcomm.jar
The main goal is to create this .exe and put all the supporting files in a folder with it, with maybe a setup/readme file to get it working on any PC.
Here is my stackup when I run just the [myprogram].jar file:
java.exe -jar [myprogram].jar
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while
loading gnu.io.RXTXCommDriver
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: no rxtxSe
rial in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
(AND MORE)
I have very little knowledge of what happens behind the scenes of java, I mostly understand the code only. I think that is why I am having trouble with this.
Thank you #hoijui,
I ended up just copying the rxtxSerial.dll to the same directory that the exe is run from and now it works. This directory also includes the RXTXcomm.jar as well. When making the exe in Launch4J I made a custom class path:
The "Main Class" I selected the jar I made from eclipse, then for the class path I added:
echo %CD%\RXTXcomm.jar
and
echo %CD%\rxtxSerial.dll.
I am not sure if this is needed to work but its there and it work so I am not messing with it.
Thanks for the help #hoijui
I'm making a basic game in Java using the LWJGL Library via Netbeans.
I've created a library with the lwjgl, lwjgl_util, and jinput .jar's, and I added -Djava.library.path=C:\LWJGL\native\windows to the "Run" category in the project's properties.
When I run the file in Netbeans, it runs perfectly with no issue. But when I run the .jar via double-clicking the file, nothing pops up (not even the momentary cmd error window, as far as I can tell). And when I run the file via command line, I get:
C:\Users\200160765>java -jar "C:\Users\200160765\Documents\NetBeansProjects\Game
\dist\Game.jar"
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: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 game.Draw.createWindow(Draw.java:198)
at game.Draw.init(Draw.java:214)
at game.Draw.run(Draw.java:56)
at game.Main.main(Main.java:9)
I've tried moving the DLL's and .jar library files around to the 'lib' folder in the same directory as Game.jar, and moving them to the same directory as Game.jar, but I get the same error. Could someone help me as to why I can't seem to get this working outside of netbeans?
you have to point the jvm to where the native files are located using a command line parameter -Djava.library.path="path/to/natives". You could use a batch (.bat) file to specify this and start your application for you.
Alternatively you can use a tool like JarSplice to create a single executable jar file from all your jars and at the same time include your native files inside it. It automates the tricky part of specifying the natives manually and provides a nicer end user experience.
To use JarSplice just select your game.jar, lwjgl.jar, lwjgl_util.jar, and jinput.jar in the jars tab. Then all the *.dll, *.so, *.dylib and *.jnilib files in the natives tab. Add your main class on the class tab and create the single executable jar.
LWJGL needs the native components for your particular platform to be in java.library.path. These are in the subdirectory native in the LWJGL distribution and end in .so on Linux, OSX and Solaris and .dll for windows.
When I had this issue, it was because i accidentally put the argument to specify the location of the natives (-Djava.library.path=/native/) in the field called 'Arguments' under the run category of the options panel, instead of 'vm Options'.
As seen here: http://s30.postimg.org/6f90akidt/Capture.png
And yet another way to do this is with Java Web Start (jnlp): http://lwjgl.org/forum/index.php?topic=3763.0
This makes sharing your project easier in some ways.
I had this problem and fixed it using jarSplice (http://ninjacave.com/jarsplice)
make sure you delete all of the preplaced natives in your jar before you create the fat jar, otherwise it will create a duplicate error
I also got the same error and then realised that I named the file "my_lib.zip" instead of "my_lib.jar". Maybe it may help someone.
Another thing to check:
If you are using a 32 bit JVM, you need 32 bit libraries. (Even on a 64 bit OS)
If you are using a 64 bit JVM, you need 64 bit libraries.
I installed and putted lwjgl library and natives to /lib folder. On eclipse Java build path setted library location and native library location. When i try to run it on eclipse, it works, but when i export it as a runnable jar, it doesn't run, and throws error:
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:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.<clinit>(Sys.java:112)
at org.lwjgl.opengl.Display.<clinit>(Display.java:132)
at Main.start(Main.java:9)
at Main.main(Main.java:31)
Tried to set run properties VM argument to -Djava.library.path="lib/" but it doesn't work too.
P.S. Tried to put the native .dll's to same folder as the jar is and it works, but I want to .dll's to be in other folder.
Thanks!
Found an answer. You can do it with custom .bat file and put there -Djava.library.path="lib/", but mine solution is to programmaticaly do that with next line:
System.setProperty("org.lwjgl.librarypath",System.getProperty("user.dir") + "/lib/");
Have you tried using JarSplice? It is a free Java .jar packaging program found here:
Ninja Cave - JarSplice
Follow the instructions. All the documentation is on this site. Just make sure that the JAR you use for your program is just an eclipse JAR file, not a runnable jar. When you start up JarSplice, add the appropriate Jars, Natives, define your main class, and simply create a runnable JAR. No need to set up VM configurations, and also you can export to Windows.exe, and MacOSX. If all goes well, you should have a double-clickable runnable jar. Hope this helps. It's how I've packaged LWJGL games in the past :)