Java - CPLEX
For a seminar at university I need to program a model with java.
Since it is a maximization problem I also need to involve CPLEX methods. Therefore I successfully installed CPLEX on my Mac OS X Version 10.5.8.
To combine CPLEX and Eclipse (I also tried it with Netbeans) I connected my current project with the CPLEX library (Properties>Library>Add Library).
Eclipse recognizes the library because the methods aren't underlinded. Additionally I committed the following argument to my run configurations:
-Djava.library.path=/Users/myname/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx
When I try to run an exemplary code (that is valid) I get the following error:
java.lang.UnsatisfiedLinkError: /Users/myname/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx/libcplex1260.jnilib: no suitable image found. Did find: /Users/myname/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx/libcplex1260.jnilib: unknown required load command 0x80000022Exception 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:6594)
at ilog.cplex.CplexI.<init>(CplexI.java:629)
at ilog.cplex.IloCplex.<init>(IloCplex.java:11067)
at ilog.cplex.IloCplex.<init>(IloCplex.java:11082)
at Knapsack.buildModel(Knapsack.java:54)
at Knapsack.main(Knapsack.java:122)
java.library.path must point to the directory containing the CPLEX shared library
try invoking java with java -Djava.library.path=...
could you please be so kind to help me, i don't know any more what to do.
Thank you for an answer
I found this question when having the same problem. followed the advice from the internet and found that I was putting the -Djava.library.path argument in the wrong place... You should really double check not only the paths but also if you put your arguments in the correct place and correctly typed. It seems silly but happens :)
Anyway, in my case, I am using NetBeans, I went to:
Project Properties
Run
in the VM Options text field:
-Djava.library.path=/Applications/IBM/ILOG/CPLEX_Studio126/cplex/bin/x86-64_osx
I hope this will help you
Make sure you closely followed the steps described in 1 for setting up eclipse.
Make sure the environment variable DYLD_LIBRARY_PATH is set in the environment eclipse is running in. See 2. First check if DYLD_LIBRARY_PATH is set. Second try to execute your java program via terminal.
Related
I read a hundred posts related to this but nothing seems to help my case.
A strange thing is happening with my commands. To start off, for the current task I need to be using textbook libraries from an algorithms book and the installer from that book also sets up Java SE 7. I have Java 8 JDK installed on my pc from before (if that is info worth knowing). So, for example, when I am running programs which involve methods from that textbook library I write java-algs4.
Last night there was something wrong with the Path variables and I wasn't able to compile anything so I was setting some of those and then things started working. However, today, when I tried running java helloworld (after doing javac helloworld.java) I got the error mentioned in the title. Moreover, I could successfully run another class file in the same directory but after I ran it once, I couldn't anymore and got the error again. This seems like black magic to me!
When I echo %CLASSPATH% I get the current directory.
Here are my current java-related PATHs set in my environment variables if this is of any help. The algs4 is the one from the textbook.
In User variables - PATH
C:\Users\Denitsa\algs4\bin;C:\Users\Denitsa\algs4\java\bin;c:\Program Files\Java\jdk1.8.0\bin;C:\ProgramData\Oracle\Java\javapath;
In System variables - PATH
_C:\ProgramData\Oracle\Java\javapath;C:\Users\Denitsa\algs4\java\bin; C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.8.0_31\bin;_
I would really appreciate your help with this, been trying to solve this for a while now!
Thanks.
I was trying to run it without the capital letters in the name. Now it is working.
Running: Mac OS X 10.8.5
I'm following the step by step instructions on the Greenfoot website:
http://www.greenfoot.org/doc/kinect/macos.html
I've dealt with all the run arounds with installing Macports for OSX 10.8, and finally installed 'boost', but for the final part, at the bottom of the site I attempt to type the code in terminal at the proper directory to configure it:
./configure --with-boost=/opt/local/include --with-wx-config=/opt/local/bin/wx-config --with-wx-prefix=/opt/local
This is what it gives me and stops at this certain point. It goes through all it's configuring and stops here:
checking for the Boost thread library... no
configure: error: cannot find the flags to link with Boost thread
I've also instead tried to install boost 1.49 instead of boost 1.50(the latest) but no luck there.
Any suggestions?
Same error on Mac OS X 10.9 - from the m4/boost.m4 file from the kinectserver-1.2 directory:
Now let's try to find the library. The algorithm is as follows: first look
for a given library name according to the user's PREFERRED-RT-OPT. For each
library name, we prefer to use the ones that carry the tag (toolset name).
Each library is searched through the various standard paths were Boost is
usually installed. If we can't find the standard variants, we try to
enforce -mt (for instance on MacOSX, libboost_threads.dylib doesn't exist
but there's -obviously- libboost_threads-mt.dylib).
So if there's a convenient way to tweak the source to point to "libboost_threads-mt.dylib" as the target for the "checking for the Boost thread library..." step, that would appear to be the ticket - still looking at what to tweak to accomplish this, though.
I am using netbeans and by setting the VMoptions to:
-Djava.library.path=C:\Users\a\Desktop\temp\sqljdbc_4.0\enu\auth\x64
my program works perfect. I am trying to run the program from command line. I have tried the following but non seems to be working:
- java -Djava.library.path=C:\Users\a\Desktop\temp\sqljdbc_4.0\enu\auth\x64\sqljdbc_auth.dll
// shows the java usage
- System.setProperty("java.library.path","C:\\Users\\a\\Desktop\\temp\\sqljdbc_4.0\\enu\\auth\\x64");
// wrote it in the code but nothing is happening.
Please let me know if I am doing something wrong or there is an alternative way to do it.
Some suggestions:
Place the DLL in your Windows/<SYSTEM> folder. Make sure to place the right one (32-bit/64-bit). Then try to run it.
Make sure the DLL you are using is the right one. Your Java JRE and NetBeans JRE may be different, e.g., 32-bit JVM vs 64-bit JVM.
I'm trying to use ZeroMQ on CentOS.
I followed the install instructions for unix like platforms
I keep getting the following exception when running:
java.lang.UnsatisfiedLinkError: no jzmq in java.library.path
However the following line fixes this problem:
export LD_LIBRARY_PATH=/usr/local/lib
What exactly is this LD_LIBRARY_PATH and why is not explained in the install instructions? Do I need to run this export everytime?
It's a way to specify where to load some native library (.so file) the app is using. You can get that variable defined in the environment in a number of ways, depending on what you need. If you are going to have the MQ start when the os boots, you could put the export in the startup shell script. Or it might go in /etc/bashrc, or it might go in ~/.bashrc It just depends on what you need.
FYI I don't know anything about ZeroMQ itself.
Some background:
On Mac OS X 10.6 using Macports and I have DYLD_LIBRARY_PATH set in my .bash_profile.
The problem:
When I run java -version I get this error:
Error occurred during initialization of VM
Unable to load native library: libjava.jnilib
By way of one helpful forum thread, I've discovered the problem is some files in my '/opt/local/lib' directory are causing trouble because of the DYLD_LIBRARY_PATH I've set.
When I remove the files starting with libgif, libjpeg, libpng and libtiff from '/opt/local/lib', the problem goes away and `java -version' works, but the ports that depend on those files break.
Anyone know of a way I can keep the files and still get java to work properly? Possibly setting the java path, which I'm not quite sure how to do and all my attempts have failed.
Thanks.
Don't set DYLD_LIBRARY_PATH. Because of this env var, the dynamic linker dyld, is finding /opt/local/lib/libjpeg.dylib etc. instead of the different /System/Library/Frameworks//ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Resources/libJPEG.dylib that it needs.
This seems to work on OS X Lion:
unset DYLD_LIBRARY_PATH
Seems one possible cause of this a file protection problem? See my post over in this other thread.