I am new to java.I have written some python scripts and need to run them from java as desired by my mentor(these scripts are to be deployed on a server).So I have installed Jepp on my windows xp.However when I run
C:\Program Files\Jepp>java -classpath jep.jar jep.Run console.py
I get
java.lang.UnsatisfiedLinkError: C:\WINDOWS\system32\jep.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1803)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1728)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at jep.Jep.<clinit>(Jep.java:136)
at jep.Run.run(Run.java:54)
at jep.Run.main(Run.java:153)
I have included the system32 folder containing jep.dll and the Program Files\jepp folder in PATH env. variable but still it is showing the same error.Are there any other directories that need to be included in the PATH variable?
Also in the readme file in jepp dir. for installation,it is given:
Also, you'll likely need to add -Djava.library.path='path to
Release folder' for testing. Or copy and register the DLL in the
System directory.
The jep.dll is already present in system32 directory.What other DLL might have been referred to here.
Ive also tried
C:\Program Files\Jepp>java -classpath jep.jar jep.Run console.py -Djava.library.path='C:\Program Files\Jepp'
but it still gives the same UnsatisfiedLinkError :(
Am I wrong in adding the -Djava.library.path command as in above or is it supposed to be added somewhere else?
I am so confused and getting all kinds of doubts as i've been struggling with this for the past 2 days :( .Even the online documentation is not so detailed and helpful.I would really appreciate any suggestions regarding this....
thanks in advance!
Related
I have a problem installing jpl library. I installed the latest swipl version (but I tried also unstable versions before):
SWI-Prolog 7.2.3 for Windows 7/8/10 64-bit edition
Then I added dependent paths to environment variables:
Variable: SWI_HOME_DIR
Value: C:\Program Files\swipl
Then I added, to Path these values:
%SWI_HOME_DIR%\lib\jpl.jar;
%SWI_HOME_DIR%\lib;
%SWI_HOME_DIR%\bin
I also added the VM argument like this:
-Djava.library.path="C:\Program Files\swipl\bin"
to make sure that Eclipse sees this folder.
After that I still get the error:
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: C:\Program Files\swipl\bin\jpl.dll: Can't find dependent libraries
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 org.jpl7.JPL.loadNativeLibrary(JPL.java:79)
at org.jpl7.fli.Prolog.<clinit>(Prolog.java:41)
at org.jpl7.Query.open(Query.java:260)
at org.jpl7.Util.textToTerm(Util.java:102)
at org.jpl7.Query.Query1(Query.java:129)
at org.jpl7.Query.<init>(Query.java:120)
I'm 100% sure, that Eclipse sees that jpl.dll file, but in my opinion, it seems that it needs some other libraries.
I know that this thread is probably duplicate of either of these:
jpl.dll: Can't find dependent libraries
JPL Can't find dependent libraries of jpl.dll
but these questions are not answered or the answers doesn't helps in my case.
I added dependent paths to environment variables:
Variable: SWI_HOME_DIR
Value: C:\Program Files\swipl
Then I added, to Path these values:
%SWI_HOME_DIR%\lib\jpl.jar;
%SWI_HOME_DIR%\lib;
%SWI_HOME_DIR%\bin
This is the installation instructions:
Put the three library files (jpl.dll, jpl.jar and jpl.pl) where each can be found:
jpl.dll must be found by the Windows kernel, and can go in any
folder on your PATH environment variable;
perhaps %SWI_HOME_DIR%\bin
or your Windows system folder
jpl.jar must be found by any Java VM's (and compilers) used
with JPL. One possibility is to put it on your global CLASSPATH.
jpl.pl is a Prolog source module, and must be found by any
SWI-Prolog engines used with JPL:
I suggest putting it in %SWI_HOME_DIR%\library and then invoking
make_library_index/1 on that folder (see a SWI-Prolog manual
for details) so that the autoloader can find it.
I would like to call a Java function that uses Cplex, from Matlab.
At the moment, I am stuck. Below is a list of things I tried, but I am out of ideas. Before I get there, let me list the versions:
Matlab version 8.3.0.532 (R2014a)
Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Eclipse with jre7 and jdk1.7.0_79
I created a package "milp.jar" and try to call the following function from Matlab:
milp.MTsolver.Plan()
In a basic version of my milp.jar, without any Cplex functionality, this goes without problems. Just as soon as I use a Cplex function in my Java class, I get in trouble. I tried the following:
To be able to use Cplex, I added the path to the javaclasspath.txt file in the Matlab folder
prefdir
The command
javaclasspath
in Matlab console indeed shows that this path is added to the Static Java Path.
But then, when calling my cplex dependent function milp.MTsolver.Plan(), I get the following error:
Java exception occurred:
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=...
Following this post, I should first load the library:
java.lang.System.load('C:\Program Files\IBM\ILOG\CPLEX_Studio1262\cplex\lib\cplex.jar');
But this gives the following error:
Java exception occurred:
java.lang.UnsatisfiedLinkError: C:\Program Files\IBM\ILOG\CPLEX_Studio1262\cplex\lib\cplex.jar: %1 is not a valid Win32 application
At his point, I tried another approach. I just copied the cplex.jar into the Matlab root folder. No success. Nor any succes when just copying the cplex.jar in the project folder in Matlab.
Then, I tried to find a cplex1262.jar, but I only found a cplex1262.dll. So I added this path to the Static Java Path. This gives the following error:
Java exception occurred:
java.lang.UnsatisfiedLinkError: ilog.cplex.Cplex.CPXopenCPLEX([I)J
The same error occurs when I run the following in the Matlab console:
java.lang.System.load('C:\Program Files\IBM\ILOG\CPLEX_Studio1262\opl\oplide\plugins\ilog.odms.ide.opllang.win32.win32.x86_64_12.6.2.0\cplex1262.dll');
A last thing I could try comes from an answer in this post.
Here, he sets
-Djava.library.path=...
in the VM Options field, but in Netbeans. I could try to do something similar in Matlab, but I have not figured out yet how.
Last, I just added the directories containing cplex.jar and cplex1262.dll to the PATH environment variable. No luck there either.
Another important note might be that I have no problem running my code in Eclipse, including Cplex functionality! It might also be worth mentioning that, in between changes, I restarted Matlab to be sure that all changes in path settings took effect.
I hope to have stated my problem clearly enough. Any suggestions on how to proceed are very welcome!
I was able to find a quick and dirty solution, which is ok for now.
First I tried to add the path to the directory containing cplex1262.dll to the
'java.library.path' as follows:
java.lang.System.setProperty('java.library.path', [path to dir])
But that did not work for me. In a quick and dirty manner, I looked up what paths were already included in this property, with the following command.
>> java.lang.System.getProperty('java.library.path')
ans =
C:\Program Files\MATLAB\R2014a\bin\win64;C:\Program Files\MATLAB\R2014a\sys\jxbrowser\win64\lib
And just copy/pasted the cplex1262.dll in the \lib directory.
That worked.
I am having some problems with linking a jnilib in java. I receive
Exception in thread "main" java.lang.UnsatisfiedLinkError: no ***.jnlib in java.library.path.
Through my research I found that this could be caused by java not knowing were the file was. So, I told it that it was in the Mac folder. I also added the file to every other folder in the project. None of this helped at all. The project is cross platform so I tried it on windows the dll's loaded just fine when I told java to look in the windows folder. I do not understand why this would work in windows and not on a Mac. Any thoughts or ideas will be welcome.
The exception output is:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no libhidapi-jni-64.jnilib in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1758)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1045)
at webstart.OmronIO.<init>(OmronIO.java:30)
at webstart.Omron.main(Omron.java:13)
The java.library.path is: /Volumes/UNTITLED/javahidapi/mac.
The path to the jinlib is : /Volumes/UNTITLED/javahidapi/mac.
On OSX, the environment variable DYLD_LIBRARY_PATH is used to find shared libraries (including .jnilib). That variable is what is used to initialize java.library.path.
If you output the value of java.library.path at the point where you attempt System.loadLibrary(), you will see the list of directories searched for the library you are attempting to load.
EDIT
See also http://create-lab-commons.googlecode.com/svn-history/r222/trunk/java/lib/HIDAPI/README.txt, which appears to apply to the specific library you're attempting to load (hidapi), and the way you're attempting to load it (webstart).
I faced the same issue. It was not loading library file in any path, even after using - Djava.library.path in application argument. I am using System.loadLibrary("test"). The library name was libtest.jnilib
The prefix and suffix will be added while executing.
I am using Mac M1 Pro. Unfortunately, it is not supported in ARM based JDKs. Switching to non-ARM JDK solved the issue.
I am developing a program that calls R functions from Java using JRI/rJava. I was coding the program in NetBeans on another machine, which was working fine (i.e. able to run the code). I have since then moved to another machine and have been running into problems.
The exact error message I am seeing is this:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
java.lang.UnsatisfiedLinkError: E:\R\R-2.13.1\library\rJava\jri\jri.dll: The specified path is invalid
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1732)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1028)
at org.rosuda.JRI.Rengine.<clinit>(Rengine.java:19)
at com.rjava.test.rtest.main(rtest.java:64)
Java Result: 1
I have read the FAQs for JRI/rJava, and have been scouring the internet for fixes, but have made no progress. Here is what I have done so far:
Created an environment variable called R_HOME: "E:\R\R-2.13.1"
Added "%R_HOME%\bin\x64" to the PATH environment variable
Added "%R_HOME%\library\rJava\JRI" to the PATH environment variable (this is where jri.dll is located)
Set the required jar files as compile time libraries (JRI.jar, JRIEngine.jar, REngine.jar) in NetBeans
set the following VM options in NetBeans: : -Djava.library.path=E:\R\R-2.13.1\library\rJava\jri (This is where jri.dll is located)
I have restarted my computer to make sure that the changes stick.
To make sure I configured things correctly, I ran the following in the command line:
java -cp E:\R\R-2.13.1\library\rJava\jri\JRI.jar;E:\R\R-2.13.1\library\rJava\jri\examples rtest
And the example java files ran fine. I'm beginning to think my new machine just hates me.
The message indicates that it the path E:\R\R-2.13.1\library\rJava\jri\jri.dll is invalid. Are you sure that path exists? Also, is E a mapped drive that is mapped to a path that has spaces in it? I'm not sure if the spaces are the issue, but it eliminates one issue. I would try just putting the dll in C:\ or somewhere very simple and seeing if it can find it there as a simple test.
Also verify that the -Djava.library.path is being passed as you think it is (you can check that with visualvm or jconsole).
You could try this:
-Djava.library.path=E:\R\R-2.13.1\library\rJava\jri -cp E:\R\R-2.13.1\library
\rJava\jri;E:\R\R-2.13.1\library\rJava\jri\JRI.jar;E:\R\R-2.13.1
\library\rJava\jri\examples
The reason I say this is that, perhaps the .dll also needs to be in the classpath as well as the library path in order for the classloader to load it? Its probably not true, but worth trying. Also is "rJava" correct? Other than that, it looks to me like your doing it right.
To locate JRI installed with rJava, use system.file("jri",package="rJava") in R.
set that path to your path (environment variables in windows),
restart your netbeans. and try to run your program again
I am getting a error message like this:
The library libraryname.dll could not be loaded by Windows. Make
sure that the library is in you Path environment variable. Exception
in thread "main" java.lang.UnsatifiedLinkError: no libraryname in
java.library.path.
This error is from me trying to run a jar file on Windows XP via cmd. I am wondering, where exactly is java.library.path? I've already added C:\Program Files\Java\jdk1.6.0_26 to my PATH but it still gives me the error. How would you go about debugging this?
Thanks.
You can simply pass java.library.path as a system property as shown below:
java -Djava.library.path=<path_to_dll> <main_class>
First you need to find out where the libraryname.dll is and add it above in "path_to_dll".
The error is basically saying it cannot find your native libraries. Java tries to locate your library by looking into java.library.path property
It's an System environment that you need so Java can find your native libraries when you run your application. Several ways to do it:
Use java -Djava.library.path=[path to your library] when running your program
From the code you could also do.
System.setProperty( "java.library.path", "/path/to/libs" );
Set it up from your IDE. An example for Eclipse can be found in this SO question How to set java.library.path from eclipse
EDIT: A good comment below pointed out that #2 will not working 100% because you might not set this prior to calling getProperty(). Missed that point and thanks for pointing that out.