java.lang.UnsatisfiedLinkError: no JCfiLib in java.library.path - java

Before anyone states duplicate. Please be aware that other questions are windows based and complain about DLLs or are not related to this library.
I have downloaded the EOCFI JAVA API from ESA which I would like to use. These include some example .java files.
I'm simply loading their entire API directory, adding the external JARs, and trying to run their examples. But I run into the following error:
java.lang.UnsatisfiedLinkError: no JCfiLib in java.library.path
I can't seem to find JCfiLib anywhere in the API or on the internet. I would imagine if I could I would simply add it to the java library path as the error states, but I have no idea what it is or where I can get it.
How can I get around this error?
I'm using eclipse on Debian Wheezy.
Any help would be greatly appreciated. Please be patient I'm not a Java programmer.
UPDATE (more details)
I realize now JCfiLib stands for "Java CFI Library" it's the library i'm using. But when I download it it's made up of 7 separate .jar files. (Visibility.jar, Pointing.jar, etc...) I reference them all as external jars.
The line it throws an error on is modelId = new ModelId(); (VisibilityExample.java:221)
error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no JCfiLib 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 EECFI.CfiId.<clinit>(CfiId.java:22)
at Visibility.example.VisibilityExample.main(VisibilityExample.java:211)

There are some native library (including a libJCfiLib.so) in the package I downloaded (linux64, in libraries/LINUX64) and you need to tell Eclipse where to find them:
see How to add native library to "java.library.path" with Eclipse launch (instead of overriding it) for example.
Also note that there are some sample provided in the package with "run script", you can also check those in order to help you with your project.
Hope that helps.

Related

Unable to load library NLPIR.dll in JNA

I try to use a word-segmentation software, I create a new java project named JNA, and import the required files into JNA dir, then I try to run it without any code modification, and MyEclipse warns me that:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'E://java//JNI//JnaTest_NLPIR//NLPIR': Native library (win32-x86-64/E://java//JNI//JnaTest_NLPIR//NLPIR.dll) not found in resource path ([file:/D:/javasoft/MyEclipse_workspace/JNA/bin/, file:/D:/javasoft/MyEclipse_workspace/JNA/lib/jna-4.0.0.jar])
I tried to:
create the same dirs and move NLPIR.dll to E:/java/JNI/JnaTest_NLPIR/, it didn't work.
move NLPIR.dll directly to JNA/bin or JNA/lib, but it didn't work, too.
I think that it is caused by the position of my NLPIR.dll. But I could not figure out how to fix it.
I would be grateful for any help or suggestions.
Ensure NLPIR.dll (and all its dependent libraries) is on %PATH%, or use -Djna.library.path=... to indicate the folder it's in.

jassimp.dll: The specified procedure could not be found

I've been working on the same problem for the past ~4 days: getting JAssimp to work (an Assimp port for Java). Before I ask this question, if ANYONE has got this to work and can provide any files, please do. I am so tired of messing with this.
Anyways, I've compiled two .dlls: jassimp.dll and assimp.dll (jassimp needs assimp.dll to work).
I've placed those in my project directory, and tried to run the project (obviously linking with jassimp.jar, built with ANT)
I get an error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\VB2013Projects\jassimpfinal\Debug\jassimp.dll: The specified procedure could not be found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1855)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at jassimp.Jassimp.<clinit>(Unknown Source)
at opengltutorials.Mesh.loadMesh(Mesh.java:131)
at opengltutorials.Tutorial.init(Tutorial.java:124)
at opengltutorials.Tutorial.main(Tutorial.java:238)
I checked the dependencies using dependency walker, and jassimp.dll shows like this:
What's happening here, and how can I fix this?

JAssimp - Can't find dependent libraries

I've compiled the JAssimp library, and I'm trying to use the library in NetBeans with a project.
I'm setting the library path in Netbeans in the 'run' options of the project as such:
-Djava.library.path=D:\VB2013Projects\jassimpfinal\x64\Debug
That path is where jassimp.dll is located.
However, when I try to run my project, I get this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\VB2013Projects\jassimpfinal\x64\Debug\jassimp.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at jassimp.Jassimp.<clinit>(Unknown Source)
at opengltutorials.Mesh.loadMesh(Mesh.java:131)
at opengltutorials.Tutorial.init(Tutorial.java:124)
at opengltutorials.Tutorial.main(Tutorial.java:238)
I've checked the dependencies with Dependency Walker, and it shows that
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module. for jassimp.dll. However, it doesn't show any functions in red, so I think this is just a red herring (I am probably wrong, though).
What's going wrong with this?
Fixed this by putting the appropriate .dll's in the working directory.

Mac + jni + java

A little background:
I have a java application that needs to talk to a third party hardware on mac. They have given me the sdk but it is not in Java. So I am trying to make jnilib that will act as a bridge between my java application and the SDK.
The issue:
I have made a small sample jnilib that talks to the SDK but when I try to use it in my java program I get the following error
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/john.doe/Desktop/eclipse/workspace/Lesson13_Jni_Smart7/bin/libSmartTest7.jnilib: Library not loaded: build/Release/SMARTResponseSDK.framework/Versions/A/SMARTResponseSDK Referenced from: /Users/john.doe/Desktop/eclipse/workspace/Lesson13_Jni_Smart7/bin/libSmartTest7.jnilib
Reason: image not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1827)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1742)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at com.learning.lesson13.JniSmart7.<clinit>(JniSmart7.java:6)
From the error it looks like my libSmartTest7.jnilib is looking for the library SMARTResponseSDK.
What I have tried
I know where the library SMARTResponseSDK is on my Mac. I tried copying it over to my working folder in eclipse but I still get the error. I have tried using the -DJava.library.path but I still get the error.
Any ideas on what the best possible approach would be.
Once you are inside JNI code, it no longer matters what java.library.path points at.
Once you are inside JNI code, all you can do is to make sure library is visible to your code via LD_LIBRARY_PATH/DYLD_LIBRARY_PATH, or you can dynamically load your library file from any location you like.
So, for you, I suggest to take a look here:
dynamic loading of library in JNI - http://jnicookbook.owsiak.org/recipe-No-018/
Calling code from shared library (adapter pattern) - http://jnicookbook.owsiak.org/recipe-No-023/
You can also benefit from compilation flags while building your JNI library and use rpath.

getting javax.mail.MessagingException

I am using javax.mail .jar file to read the mail messages. But when i m running the code i am getting the following exception.
I added mail.jar in classpath.
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingE
xception
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: MasterProcess. Program will exit.
any suggetionsn to solve this issue please ...
You're not getting a MessagingException, the VM is complaining that it can't find MessagingException (although it's probably that it's looking for it because it wants to throw it, but those are issues for later).
Check if your mail.jar actually contains this class, and check if your mail.jar really is on the classpath.
The last thing that could happen is that the class is incompatible with your version of Java. Classes compiled for 1.5 won't run on 1.4, for example.
Working in eclipse and not in command line clearly say that there is multiple versions of mail jar present in the project.
Ex:
You have 3 Jars , Jar X, Jar Y and Jar Z.
With out you knowing JAR X might be already be bundled inside JAR Z ( in this case mail jar but some different version.
So what is the problem in having multiple version of same jar ?
You have two different versions and you will not know which will be referenced in your project. (so if you are looking for some class from mail-2.jar in your project you will get class not found exception if the reference is made to mail-1.jar by class loader)
So how come its working properly on Eclipse ?
In eclipse you can see there is an option for ORDER the library, these will be reference in the same order, but while running in command prompt we used to load the as lib/* which loads all to gather and we will not know which lib will get loaded first.
How to identify the culprit and fix the issue ?
Option 1 :
See docs page / user guide of the libs you are using to see what they have in them.
Option 2 :
In eclipse move the JAR in question (mail.jar here) to TOP in the class path order. (your program should work now)
Now bring down the order one by one to see where you get the error. (if you wish to find the jar which is causing this issue , duplicate reference)
Extract the jar which has the duplicate reference remove the duplicate inside the JAR and repackage it. (if required)
Also be sure you're having also the java activation.jar jar.
Are you by any chance working with an App Server (eg. Jboss), if so, just check classloading model (in jboss with single classloading model you may be loading a not so up-to-date version of the jars)
I've also faced the same error. It happens to me that while compiling i used the jars correctly. While running it on command line i noticed the mail.jar (javamail API) was not included.

Categories

Resources