I'm trying to make a game and it runs fine in eclipse, but I get this error when I export and run it as a jar file.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl64 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)
at org.lwjgl.Sys$1.run(Sys.java:72)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:87)
at org.lwjgl.Sys.<clinit>(Sys.java:117)
at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
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 ultra.game.core.MainGame.main(MainGame.java:1827)
I have tried so many things. I set the natives location to the native folder and I checked inside and lwjgl64 is in there. Any help?
LWJGL uses its own variables for the path to the native libraries:
System.setProperty("org.lwjgl.librarypath", new File("pathToNatives").getAbsolutePath());
If you kept the file structure from the LWJGL package you can use something like this:
switch(LWJGLUtil.getPlatform())
{
case LWJGLUtil.PLATFORM_WINDOWS:
{
JGLLib = new File("./native/windows/");
}
break;
case LWJGLUtil.PLATFORM_LINUX:
{
JGLLib = new File("./native/linux/");
}
break;
case LWJGLUtil.PLATFORM_MACOSX:
{
JGLLib = new File("./native/macosx/");
}
break;
}
System.setProperty("org.lwjgl.librarypath", JGLLib.getAbsolutePath());
This means that you do not have the native library named "lwjgl64" in a place so that Java can find and load it, or that you are using a 32-bit JVM and you are trying to load a 64-bit native library (or vice versa) - if you want to use native libraries, they must have the same "bitness" as the JVM you are using.
On Windows, the native library would be in a file lwjgl64.dll; on Mac OS X or other Unix-like systems it would be lwjgl64.so. Find this file, and then set the system property java.library.path using the -D option when you start your program, for example:
java -Djava.library.path=C:\MyProject\lib com.mypackage.MyProgram
where C:\MyProject\lib would be the directory that contains the DLL.
Related
I'm trying to run Iotivity Simple Clent in Java. I have cloned Iotivity project https://github.com/iotivity/iotivity and I have created an eclipse project that includes all the required Iotivity Java classes plus the classes for the SimpleClient from java-examples folder and I have no error so far.
When I try to run SimpleClient.java I get
Exception in thread "main" java.lang.UnsatisfiedLinkError: no ocstack-jni 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)
at org.iotivity.base.OcPlatform.<clinit>(OcPlatform.java:39)
at org.iotivity.base.examples.SimpleClient.startSimpleClient(SimpleClient.java:75)
at org.iotivity.base.examples.SimpleClient.main(SimpleClient.java:524)
I have installed SCONs and Gradle but I don't know how to proceed in order to build and create the "ocstack-jni" or any other library that is required to be loaded. My operating system is Windows 10.
You need to build with BUILD_JAVA=1 and the JAVA_HOME environment var must not be pointing to your current java install.
I have downloaded this library from this link http://rxtx.qbang.org/wiki/index.php/Main_Page. I have google a number of pages and first I add via the build path method and add the RXTXcomm.jar. Then I have also add here C:\Program Files(86)\Java\jre7\lib\ext folder also added this .jar file. Yet I still getting this error when I try to run or compile my programme on eclipse
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path thrown while loading gnu.io.RXTXCommDriver
Exception in thread "main" java.lang.UnsatisfiedLinkError: no rxtxSerial 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)
at gnu.io.CommPortIdentifier.<clinit>(CommPortIdentifier.java:123)
at read1.TwoWaySerialComm.connect(TwoWaySerialComm.java:21)
at read1.TwoWaySerialComm.main(TwoWaySerialComm.java:108)
You need to set java.library.path when you are starting your program. This will let Java be able to find the native C code that is used in order to talk with the serial ports.
This library as been deprecated. Use new libraries like serialpundit, pyserial etc.
Why it seems that is impossible to load a library (.dll) in Java, if it is not located in /jre/bin folder. It's crazy, but I have 2 dll's:
aa.dll
bb.dll, which depends on aa.dll
If I copy these dll's in C:\Tmp the following code it is not working.....
If copy these dll'd in C:\Program Files\Java\jre1.8.0_25\bin, the same code it's working.
The code, very simple:
public class Main {
public static void main(String[] args) {
System.load("C:\\Tmp\\ftd2xx.dll");
System.out.println("ftd2xx.dll loaded");
System.load("C:\\Tmp\\JD2XX.dll");
}
}
The error (result):
ftd2xx.dll loaded
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jd2xx 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)
at jd2xx.JD2XX.<clinit>(JD2XX.java:729)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at Main_02.main(Main_02.java:7)
To be more confusing, one library I can load from c:\Tmp (aa.dll), the other one I cannot (bb.dll).
This last one requires to reside in C:\Program Files\Java\jre1.8.0_25\bin.
If somebody has any useful idea, I will appreciate very much.
I tought the JVM does not want to load possible dangerous, or untrusted native code? And if it resides in the jre folder it consider the code is safe? But it is jus an ideea.
Thank you.
I confirm the same:
Windows 7(64bit);jre1.8.0_102(32bit);DLL's(32bit);
Exactly the same but in my case one dll(aa.dll) is dependent on another bb.dll (aa.dll->bb.dll)
aa.dll can be loaded from anywhere (a projects lib path for ex), but only and only if I copy bb.dll to jre1.8.0_102\bin directory; No chances to load otherwise. Tried various combinations to set -Djava.library.path=project_path\lib, to set system PATH=project_path\lib, copy both dll's to windows\system32 - nothing helps, the only chance is to have it on jre\bin path.
AN UPDATE:
And you have answered your question your self. It's a security:
Go to -> Java Control Panel -> Advanced -> Mixed code ..
Set "Disable verification.."
and aa.dll loads successfully. Both stored in project_path\lib
I've looked through a number of the UnsatisfiedLinkError threads on here and nothing seems to quite fit my problem.
I am trying to get this api working: 7ZipBind
However I am having an issue, and cant get the thing to work. I am running some of its example code from the commandline like so:
C:>java -classpath
"/sevenzipTest.jar;/sevenzipjbinding-AllWindows.jar;\sevenzipjbinding.jar"
com.poc.sevenzip.SevenZipSimple c:\archive\test.zip
However when I try to run it I get the error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\Users\XXXX\AppData\Local\Temp\SevenZipJBinding-9640553\lib7-Zip-JBinding.dll: Can't
find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at net.sf.sevenzipjbinding.SevenZip.initSevenZipFromPlatformJARIntern(SevenZip.java:428)
at net.sf.sevenzipjbinding.SevenZip.initSevenZipFromPlatformJAR(SevenZip.java:235)
at net.sf.sevenzipjbinding.SevenZip.ensureLibraryIsInitialized(SevenZip.java:578)
at net.sf.sevenzipjbinding.SevenZip.openInArchive(SevenZip.java:567)
at com.poc.sevenzip.SevenZipSimple.runZip(SevenZipSimple.java:25)
at com.poc.sevenzip.SevenZipSimple.main(SevenZipSimple.java:64
What I am confused about, is why it says it cant locate the libraries (dll files), when the libraries are stored within the <file_path>/sevenzipjbinding-AllWindows.jar file... I am obviously not doing something correct here, and was hoping some1 can give me some pointers.
Cheers
The bug fix was released. Please, use version 1.06rc or above.
Download URL:
All versions
4.65-1.06rc-extr-only
The following instructions are for Windows x86 and 7 Zip JBinding version 4.65-1.05 RC. Download the following DLLs.
libstdc++-6.dll
libgcc_s_dw2-1.dll
gpsvc.dll
sysntfy.dll
Add the DLLs into the Windows-x86 directory in sevenzipjbinding-AllPlatforms.jar. Then append the following lines to sevenzipjbinding-lib.properties in the Windows-x86 directory in the jar.
sevenzipjbinding.libname.3=gpsvc.dll
sevenzipjbinding.libname.4=libgcc_s_dw2-1.dll
sevenzipjbinding.libname.5=libstdc++-6.dll
sevenzipjbinding.libname.6=sysntfy.dll
Instead of modifying the jar file, one could put the DLLs in the PATH (not classpath).
In order to figure this out, I extracted lib7-Zip-JBinding.dll from sevenzipjbinding-AllPlatforms.jar. I then opened the file in Dependency Walker.
I am trying to load a video file with javacv but I am facing some problems.
I managed to compile an application that will show an image on screen so I assume that my setup is ok.
The code I am using is the following.
import java.io.File;
import com.googlecode.javacv.CanvasFrame;
import com.googlecode.javacv.FFmpegFrameGrabber;
public class TestCV{
public static void main(String[] args) throws Exception {
File f = new File("input.mp4");
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(f);
final CanvasFrame canvas = new CanvasFrame("My Image");
canvas.showImage(grabber.grab());
}
}
Here is the error
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\takas\AppData\Local\Temp\jniavutil3690549951281752227.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:337)
at com.googlecode.javacpp.Loader.load(Loader.java:271)
at com.googlecode.javacv.cpp.avutil.<clinit>(avutil.java:76)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.googlecode.javacpp.Loader.load(Loader.java:291)
at com.googlecode.javacv.cpp.avcodec.<clinit>(avcodec.java:87)
at com.googlecode.javacv.FFmpegFrameGrabber.<init>(FFmpegFrameGrabber.java:73)
at com.googlecode.javacv.FFmpegFrameGrabber.<init>(FFmpegFrameGrabber.java:69)
at tester.t.JavaFlow.main(JavaFlow.java:13)
Do I have to use separate ffmpeg dlls? There is one ffmpeg dll in the opecv bin folder.
If I have to do this I will need a better way to include them using eclipse. Until now I just add the folder to path variable. For example I added this to make opencv work.
C:\opencv\build\common\tbb\ia32\vc10\;C:\opencv\build\x86\vc10\bin\;
some days back i got same error and i solved this by following procedure,
download ffmpeg precompiled file for windows
for window 32
http://ffmpeg.zeranoe.com/builds/win32/shared/ffmpeg-0.7.1-win32-shared.7z
for window 64
http://ffmpeg.zeranoe.com/builds/win64/shared/ffmpeg-0.7.1-win64-shared.7z
extract folder some where on hard-disk copy all dlls put them into system32 folder. basically these dll required to be in you path so that java program can access them