Jinput library not found in java.library.path - java

I am trying to use jinput with a wrapper library (procontroll) in a Java application on OS X.
The problem is in the jinput library. When control gets to net.java.games.input.OSXEnvironmentPlugin's System.loadLibrary call, which looks for "jinput-osx", this call throws an UnsatisfiedLinkError.
I have downloaded the latest jinput libraries from jinput.dev.java.net, discovered the java.library.path for my application by println()'ing it, and put both the jinput.jar and libjinput-osx.jnilib files in this directory.
Does anyone have ideas as to why this library isn't loading or how to fix it? Thanks.

go to Project->Propertity->Java Build Path->Libraries-> JRE->Native Livary->edit:
add the library folder containing jinput-osx as the external folder

Related

still experiencing linker error despite linking the java jar file in visual studio code

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.

OpenCV 4.3.0 java.lang.UnsatisfiedLinkError in Eclipse

I'm trying to do some template matching with the Java binding of OpenCV 4.3.0 in Eclipse, but attempting to load the template image always results in this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.imgcodecs.Imgcodecs.imread_0(Ljava/lang/String;I)J
The line of code where this exception is thrown is this:
flowerTemplate = Imgcodecs.imread("/templates/flowerpot_white.png", Imgcodecs.IMREAD_COLOR);
I have tried a number of solutions suggested on similar questions on StackOverflow and elsewhere on the internet, including:
Pointing at the native library folder with the "Native library location" variable in the user library definition in Eclipse.
Adding the native library folder location to my PATH variable.
Adding the native library .dll location to my PATH variable.
Setting up the Eclipse run configuration to add the native library folder & .dll locations to the PATH and CLASSPATH variables.
Loading the library with the appropriate Java code, in each of the three ways I saw it suggested, in three different places which all run before the code that throws the exception.
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
System.load(<path_to_the_dll>);
File opencvLibrary = new File(System.mapLibraryName(Core.NATIVE_LIBRARY_NAME));
System.load(opencvLibrary.getAbsolutePath());
Placing the .dll in question into my source folder and every subfolder. I am running it from within Eclipse, so this is also the program's working directory.
UnsatisfiedLinkError is a runtime exception that happens when running your Java program. So placing your file in the source folder will not work.
You need it to be available in a place that your program can find it.
See this article for example:
https://www.javaworld.com/article/2077520/java-tip-23--write-native-methods.html
In it they place the library in Linux's library path. In windows you'd similarly place it in the current directory (where you're running from) or in some shared location.
This article explains Window's dll search order: https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order
You shouldn't need to explicitly call System.loadLibrary() yourself. That's the library's responsibility.
Your problem is that OpenCV is improperly installed on your machine or inaccessible from Eclipse.
For instructions on how to make in work in Eclipse see:
Add .dll to java.library.path in Eclipse/PyDev Jython project
After removing every load method and then adding them back one-by-one, I determined that the issue was most likely caused by Eclipse loading the native library folder twice.

UnsatisfiedLinkError : Native library 'wcepeer' not found (Mysaifu)

I'm trying to code an application in Java that can be executed in a Windows CE operating system.
For this, I use Eclipse on my Windows PC and then transfer the .jar file into my "smaller" system that operates with Windows CE. The .jar file is then executed with the Mysaifu JVM (because we need a JVM to execute a Java program in Windows CE).
So I started with a simple application that will launch a window (with JFrame) and when I tried to execute it, I got an error message :
java.lang.UnsatisfiedLinkError: Native library 'wcepeer' not found (as
file 'wcepeer') in gnu.classpath.boot.library.path and
java.library.path
I've tried to verify if the file representing the native library (wcepeer.dll) is in the correct folder, and I could see that the file is there with another library files, for example wcesound.dll, wcesecurity.dll, etc. Normally these files are provided in Program Files/Mysaifu JVM/jre/bin when I installed the JVM on my Windows CE system.
I've also tried to verify the presence of the wcepeer library with System.loadLibrary() :
try {
System.loadLibrary("wcepeer"); } catch(UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e); }
The result was :
Native code library failed to load. java.lang.UnsatisfiedLinkError: Native library 'wcepeer' not found (as
file 'wcepeer') in gnu.classpath.boot.library.path and
java.library.path
However when I replaced "wcepeer" with "wcesound" for example, there was no error. So I suppose that there's a problem with the wcepeer.dll file, but I've no idea how to solve it. I searched everywhere on the net, there's only a forum about this but it doesn't help too much.
Thanks in advance for helping.
Kindly regards,
You can use dependency walker (http://www.dependencywalker.com/) to open your DLL (it works also on CE dlls, since they use the same format as Windows ones) and see what dependencies this DLL has.
It may be that other DLLs are required (if they are statically linked via export lib your DLL will fail to load anyway) or that the DLL requires some system DLLs or APIs that are not supported on your device.
Windows CE is a componentized OS so you may have a different set of APIs, depending on the components you included in the OS image.

JNotify on Mac OS X?

I want to try JNotify, the plugin library for watching file system changes, but cannot figure out how to configure it. The web page for JNotify says that "java.library.path should point to the location of the native libraries that comes with jnotify (dlls, so dylibs etc)". I am rather new to Mac OS X and don't really know how to do this. I'm using NetBeans and was hoping there was a simple way of adding it to the path in there. I tried it by simply adding the jar file to the Libraries node in the project, and importing it by "import net.contentobjects.jnotify.*;", but that didn't help. I'm getting this:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jnotify in java.library.path
It also seems I need to add native libraries (.so file for Mac I guess) into the same path.
So how do I do this?
java.library.path is a Java system variable, you have to set this particular one by using the -D switch when launching the program:
java -Djava.library.path=/path/to/dylibs your.MainClass
It should be possible to tell Netbeans to add some command line parameters when starting your program somewhere in your project's properties.
On OS X, the directory you want is wherever the .dylib files are, not the .so ones.
JNotify does NOT work on MAC OSX 10.6.8. As simple as that. :( On Linux works fine! File modified is not correctly reported no matter what you try.

java.lang.UnsatisfiedLinkError

I am trying to use an applet I downloaded. I get the following error when using it
Can't load library 'friend'.
java.lang.UnsatisfiedLinkError:no friend in java.library.path
No resource '/libfriend.so' found.
Please help. Thank you.
the application is looking for a native library called libfriend.so in your path. I'm assuming you're on linux, if so and you have the .so file you can add it to your path, if you are on windows you are out of luck.

Categories