maven pass arguments to pom java.library.path cplex - java

I am trying to resolve this error that I keep getting:
java.lang.UnsatisfiedLinkError: no cplex1262 in java.library.path
java.library.path must point to the directory containing the CPLEX shared library
try invoking java with java -Djava.library.path=...
Exception in thread "main" java.lang.UnsatisfiedLinkError: ilog.cplex.Cplex.CPXopenCPLEX([I)J
at ilog.cplex.Cplex.CPXopenCPLEX(Native Method)
at ilog.cplex.CplexI.init(CplexI.java:5722)
at ilog.cplex.CplexI.(CplexI.java:611)
at ilog.cplex.IloCplex.(IloCplex.java:10384)
I am using maven with java and I am trying to call cplex library. I think something needs to change in the pom file but i dont know what. Please help. Thanks.

One possible cause for could be your dll being in 32 or 64 bits and your java being in the opposite architecture.
Try verifying that your java and cplex.dll match. I got this information from the below post UnsatisfiedLinkError, despite setting Djava.library.path variable

Related

JNI library missing

I am trying to run a test file InspectVM from libguestfs library inorder to have accesss to a disk image in windows. However, I have the following errors on my console
run:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no guestfs_jni in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at madjava.com.redhat.et.libguestfs.GuestFS.<clinit>(GuestFS.java:51)
at madjava.examples.InspectVM.main(InspectVM.java:30)
C:\Users\CyberSOFONET\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)#
I searched allover the internet and find that I should set java.libraly.path pointing to location of the guestfs_jni. my major problem is that I do not have any file with that name guestfs_jni. Do I need to make one myself or can I find it somewhere. any kind of help is appriciated. am a newbie in JNI so I dont have much imformation on it
You're looking for a file called guestfs_jni.dll. Usually the native library comes with the jar file.
From http://libguestfs.org/guestfs-java.3.html:
Libguestfs for Java is a Java Native Interface (JNI) extension, supplied in three parts: libguestfs.jar, libguestfs-VERSION.jar, libguestfs_jni.so, libguestfs.so
So the distribution comes with libguest_jni.so which ist for Linux and not for Windows. IIRC, there is no libguestfs for Windows. So you would first have to find out if it is even possible to compile libguestfs using Cygwin and if yes build it yourself.
If you're on Windows 10 you could try installing libguestfs and a Java runtime for the Linux subsystem and run inside the subsystem.

Cannot get Jep to work with Eclipse

For one of my projects I have the need to mix Java with some well established Python code, so I turned my attention to JEP as this seems to be the perfect solution to my problem. I am using Java 1.8 and Python 3.6 on Mac OSX, and my Java IDE is Eclipse.
Unfortunately, I struggle to get this to work, mainly because I am really a newby I think.
In Eclipse, I have set my Build path to include the 'jep-3.7.1.jar', and I have also linked the path to the native '.so' file to 'Users/me/anaconda3/lib/python3.6/site-packages/jep/'. So it seems like I have done everything I need, but when I try to run a simple code that calls for a Jep object I get the following naste exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/me/anaconda3/lib/python3.6/site-packages/jep/jep.cpython-36m-darwin.so: dlopen(/Users/me/anaconda3/lib/python3.6/site-packages/jep/jep.cpython-36m-darwin.so, 1): Library not loaded: #rpath/libpython3.6m.dylib
Referenced from: /Users/me/anaconda3/lib/python3.6/site-packages/jep/jep.cpython-36m-darwin.so
Reason: image not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1861)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at jep.Jep.<clinit>(Jep.java:217)
at mixingPython.mixJvcPyth.getDataFromPython(mixJvcPyth.java:11)
at mixingPython.mixJvcPyth.main(mixJvcPyth.java:29)/
I am sure that this is basic, but if anyone could help it would be great!
Cedric

java.lang.UnsatisfiedLinkError: no so in java.library.path

When i'm trying to load the .so file from the Java, i'm getting error like this.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no yeslib.so in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at com.rct.micros.util.GetCustClass.getScratchCode(GetCustClass.java:76)
at com.rct.micros.util.GetCustClass.main(GetCustClass.java:39)
I have tried System.load(absoulte path) and System.loadLibrary(sofilename). Both are giving the same error. When i copy this so file into usr/lib/jvm package, it is working..
can anyone help how to get this solved using Java. i'm running on linux box.
It's possible that the library is on your path, but it can't be loaded for some other reason.
A trick I've used to debug problems like this is to run java -Xrunsofilename
-Xrun is the JVM option to load JVMPI libraries (the old profiling interface). If it succeeds, it will load the library and complain that it's not an agent library. But if it fails (hopefully!) it will print an error message. This is usually a more descriptive error message than what you get from the UnsatisfiedLinkError.

ZMQ - libzmq.so.3: cannot open shared object file: No such file or directory

I'm trying to embed zeroMQ in my app, I followed this guideline to install ZMQ, so till here everything works fine.
I have this line of code in my app:
ZMQ.Context m_context = ZMQ.context(1);
but above line of code raise below exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/libjzmq-812339378390536247.lib: libzmq.so.3: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1939)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1864)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1825)
at java.lang.Runtime.load0(Runtime.java:792)
at java.lang.System.load(System.java:1059)
at org.zeromq.EmbeddedLibraryTools.loadEmbeddedLibrary(EmbeddedLibraryTools.java:136)
at org.zeromq.EmbeddedLibraryTools.<clinit>(EmbeddedLibraryTools.java:22)
at org.zeromq.ZMQ.<clinit>(ZMQ.java:38)
at com.castaclip.verticals.Messenger.<init>(Messenger.java:125)
at com.castaclip.verticals.PushMessenger.<init>(PushMessenger.java:30)
at com.castaclip.verticals.pushserver.App.setup(App.java:60)
at com.castaclip.verticals.pushserver.App.main(App.java:41)
The error is exactly pointing to this line.
P.S: its a little bit difficult to fully explain this question.. if you have any question plz let me know. thanks.
If you've successfully built libzmq and jzmq in that order, I would run:
$ sudo ldconfig
to update the system library cache. Then I would check to see if LD_LIBRARY_PATH is defined like Raffian mentioned, or set your library path explicitly to something like:
$ java -Djava.library.path=/usr/lib:/usr/local/lib
Finally I tried to figure out the problem.
I was using zeromq-2.1.10 and this was part of the problem.
So I installed zeromq-3.2.3 from the source and problem resolved.
I encountered a mystifying instance of this message when I:
# java -Djava.library.path=/usr/hf/zmq/lib/ -cp '/usr/hf/lib/*:.' com.zmqtest.MA
Exception in thread "main"
java.lang.UnsatisfiedLinkError: /usr/hf/zmq/lib/libjzmq.so:
libzmq.so.3: cannot open shared object file: No such file or directory
which was fixed with a solution that makes no sense at all to me:
# LD_LIBRARY_PATH=/usr/hf/zmq/lib/ java -Djava.library.path=/usr/hf/zmq/lib/ -cp '/usr/hf/lib/*:.' com.zmqtest.MA
wierd.

UnsatisfiedLinkError - What can this error mean? Every hint is useful!

In Eclipse I get this eror:
Exception in thread "main"
java.lang.UnsatisfiedLinkError:
com.nokia.mid.impl.isa.util.SharedObjects.nativeSetTable(Ljava/util/Hashtable;)Ljava/util/Hashtable;
I can see SharedObjects, but nativeSetTable doesn't seem to be a method. It might however be hidden -> I don't have access to the source code.
This was my code:
connection = (HttpConnection)Connector.open(this.url);
This is the trace:
Exception in thread "main" java.lang.UnsatisfiedLinkError:
com.nokia.mid.impl.isa.util.SharedObjects.nativeSetTable(Ljava/util/Hashtable;)Ljava/util/Hashtable;
at
com.nokia.mid.impl.isa.util.SharedObjects.nativeSetTable(Native
Method) at
com.nokia.mid.impl.isa.util.SharedObjects.createTable(SharedObjects.java:465)
at
com.nokia.mid.impl.isa.util.SharedObjects.(SharedObjects.java:181)
at
com.nokia.mid.impl.isa.io.GeneralSharedIO.(GeneralSharedIO.java:67)
at
com.sun.midp.io.ConnectionBaseAdapter.checkForPermission(ConnectionBaseAdapter.java:236)
at
com.sun.midp.io.ConnectionBaseAdapter.openPrim(ConnectionBaseAdapter.java:205)
at
com.sun.midp.io.ConnectionBaseAdapter.openPrim(ConnectionBaseAdapter.java:178)
at
com.sun.midp.io.InternalConnector.openPrim(InternalConnector.java:254)
at
com.sun.midp.io.InternalConnector.open(InternalConnector.java:153)
at
javax.microedition.io.Connector.open(Connector.java:138)
at
javax.microedition.io.Connector.open(Connector.java:120)
at
javax.microedition.io.Connector.open(Connector.java:104)
I think that nativeSetTable() is protected or private, that's why you don't see it. And moreover nativeSetTable() is a native method, which means that it is based on native code (already compiled for a specific processor and available in a specific lib [ie. a DLL]).
UnsatisfiedLinkError means that this particular method couldn't be retrieved and executed properly.
Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native.
This means that your Java ME emulator must have missing librairies. You should try to reinstall it.
Resources :
Javadoc - UnsatisfiedLinkError
I guess you are coupling your source code with the wrong version of the nokia mid library.
It could be that your runtime classpath is using a different version of the jar where SharedObjects lives, when compared to your compile-time classpath in Eclipse. I would double-check your classpath settings.
Ok, I found one reason:
I created a test class in java to test my code, just a plain java file (with main method). And I ran it as a plain java application. Then, it doesn't work. But after I tried it in a Midlet, I didn't get the error!

Categories