After exporting my game to jar it does not work.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jinput-dx8_64 in java.library.path
I read that I have to put the files anywhere in my computer and add the .dll files path to java.libraty.path, but, will it work if I try the game in another computer?
Tanks :D
If you are working on windows, just add the path of the dll file along with the java path in environment variable. For example. If your dll file is present in jdk/jre/bin,path=C:\Program Files\Java\jdk1.8.0_25\jre\bin. Just try this one. Once worked for me.
In the newest version of LWJGL3, the native files are contained inside jars and your application can be exported to a jar very easily by simply including the jars containing the native files on the classpath. LWJGL3 can be download from here: https://www.lwjgl.org/download. This solution will work no matter what machine the game is played on, as long as the native jar corresponding to the OS is included in the game's jar.
Related
I am trying to build a small personal project with opencv. I included the path to the opencv jar file in visual studio using the java dependencies then referenced libraries but i get the linker error: Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java430 in java.library.path. I have no idea what else i could do
UnsatisfiedLinkError isn't about jar files.
It's about 'native' files. These are generally stored as a .jnilib file on mac, as a .DLL on windows, and as a .so file on on most unixen.
They cannot be in jar files.
Some libraries will put in some effort and ship a whole bevy of them (as each architecture and OS has a unique dll/jnilib/so file that is needed) inside the jar, will find the 'right' one for your arch/os combo, unpack it someplace, and try to load it live.
This is either not working, or this library isn't doing that. Presumably the opencv site contains a tutorial on how to get it running; as native files are required, it's a bit more involved than 'just download, add to classpath, and voila'. I suggest you follow it precisely.
If you do have something that seems suitable (probably called opencv_java430.dll or whatnot), start java with java -Djava.library.path=/directory/containing/that/file the.rest.of.your.java.args - that should help.
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 am using Jacob jar file in my java application.
This Jacob jar file comes with a .dll file. I have added Jacob jar file to my classpath. But when I execute my application a runtime error occurs as
"couldn't load jacob-1.15-M3-x86.dll file"
How can I load this .dll file?
Edited:=================================================================================
I had set the "path" environment varaible to the dir that contains my .dll file and loading that .dll file as follows
static {
System.loadLibrary("jacob-1.15-M3-x86.dll");
}
but the following error occured
java.lang.UnsatisfiedLinkError: no jacob-1.15-M3-x86.dll in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at TemplateClass.TemplateClass.<clinit>(TemplateClass.java:14)
The 'jacob-1.15-M3-x86.dll' needs to be in a place where your the operating system can find it. You have a few options here:
You can place the .dll file in the directory you started your application from. If you have a batch script to start your application, it would be that directory. If you are starting in some sort of application server, it would typically be the 'bin' directory.
You can place the .dll file somewhere in the %PATH% environment variable. I may be easier to just update your PATH environment variable to include the directory that contains your .dll file.
Another option is to place your .dll into the %SystemRoot%\system32 directory. Usually this is 'C:\Windows\system32'. This option is not usually recommended unless it is a shared library like the MSCVRT runtime.
One other possible issue you might have. If the .dll is compiled as 32-bit, then you must be running in the 32-bit Java runtime. Likewise, if it is a 64-bit .dll it needs to be run in a 64-bit JRE.
Ah, that's not a compilation error but a runtime error.
My guess would be that your DLL needs to be on the PATH. Not CLASSPATH, but PATH, because that's where Windows looks for DLLs. Try either extending your PATH to include the location of your DLL, or do what many other people do: Dump the DLL into \Winnt\System\System32 or whatever the system directory is called on your box. Wherever all the other DLLs are, in other words.
Update
The error message you post, thankfully, is pointing out the exact problem. You can solve it by putting the directory containing your DLL into java.library.path This Sun forum thread shows a nice example: http://forums.sun.com/thread.jspa?threadID=627890
Actually, that's a lot less clean than it should be; this seems to be one of the "shadier" areas in Java. The thread wanders around a lot, I do advise you to read all the way through to see some problems and solutions. I think you'll be able to succeed with a little trial and error.
Other options :
set the property java.library.path to the directory containing the dll. Example :
java -Djava.library.path="path/to/directory/containing/the/dll" -jar appli.jar
in the code, load the dll explicitly, with System.load.
You need to set LD_LIBRARY_PATH. This will give you all the right steps to follow.
When you use System.loadLibrary() don't include the .dll at the end.
Also, if you are not setting java.library.path to point to the folder containing the DLL then the DLL should be in the directory where you launch your Java application from.
I had the same problem.
I see that the question is not "answered", so maybe none of the options above worked.
One of my last hypothesis was that the Jacob.dll is missing its dependency.
What I did was to get depend and check if all the dependence, used by Jacob are loaded.
Of course this works for Windows.
Cheers!
I'm having a difficult time figuring this one out. I have an eclipse project where I created a user library which includes the jar file opencv_java245.jar.
I've tried everything I can think of, adding the jar to the path, adding the directory of the jar to the path variable.
I checked my java versions, I've tried VM arguments in run config.
I still get the same UnsatisfiedLinkError on this line System.loadLibrary("opencv_java245");
Right now I have a user library with opencv-245.jar located in C:\OpenCV\opencv\build\java
The Native Library Location for it is located in C:/OpenCV/opencv/build/java
My PATH variable also has that same location added to it.
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
this the code for detect default dll file..
Actually for future reference for anyone I found the solution. Inside the java folder for OpenCV there is a x64 and x86 folder containing dll files for OpenCV. Copy over either 64 bit or 32 bit dll file to your java folder for OpenCV and it should work.
I'm currently working on a game based on Slick2D, but I ran into a problem.
When I try to run my game (no matter whether from dist or ide), I get the following error:
java.lang.UnsatisfiedLinkError: no jinput-linux64 in java.library.path
My directory structure is as following:
./lib contains all the .jar's for libraries
./natives contains the .dll's, .so's and .jnilib's
If I go to project options, and add -Djava.library.path=./natives to VM options, it works properly. But in that case, I'd need to have all the native libraries inside the root folder of the dist. So I want to have a separate folder for all the natives, so my first line in my main has this:
System.setProperty("org.lwjgl.librarypath", System.getProperty("user.dir") + "/natives");
But for some reason, this doesn't give a standard linking error (e.g. lwjgl not found) but for some reason picks jinput-linux64, but jinput is added as a library and is in the natives folder.
Is there anything I've done wrong or is there a better approach to distributing my game effectively overall?
Thank you !
What is wrong with placing the native libraries in your distribution? You cannot rely on your audience to have the libraries your application needs. Here is how I distribute stuff I make with slick:
MyFancyGame (Top directory)
-- libraries (mine and slick and lwjgl jars here)
-- lwjgl
-- native (dlls and so files go in here)
In the top directory I include a shell script & a batch file which contains one line:
java -ea -Djava.library.path="libraries/lwjgl/native/" -cp "libraries/*" com.MyGame.Main
This works on every computer I deploy to so long as they have java installed.