1

I'm trying to run a file.java and file.class for which I need to use a library of Cplex (optimization problem) using

$ javac -cp /home/apps/cplex/12.6.1/cplex/lib/cplex.jar file.java
$ java -cp /home/apps/cplex/12.6.1/cplex/lib/cplex.jar:. file

which was recommended when I asked in Compile Cplex in Java in linux . I finally ended the correction of my file (thing that worked in windows didn't in Linux) and the first line worked, but in the second one I got this error...

java.lang.UnsatisfiedLinkError: no cplex1261 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:6608)
        at ilog.cplex.CplexI.<init>(CplexI.java:629)
        at ilog.cplex.IloCplex.<init>(IloCplex.java:10194)
        at ilog.cplex.IloCplex.<init>(IloCplex.java:10209)
        at memoria.bosques.problemafull(bosques.java:11395)
        at memoria.bosques.main2(bosques.java:17829)
        at memoria.bosques.main(bosques.java:18014)

I tried replacing java -Djava.library.path=/home/apps/cplex/12.6.1/cplex/lib/cplex.jar instead of -cp /home/apps/cplex/12.6.1/cplex/lib/cplex.jar but didn't work either. The error occur in the fist time I define something of Cplex(before this was running fine)

IloCplex cplex = new IloCplex();

what can I do to solve my problem?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Emaneitron
  • 83
  • 9

1 Answers1

0

You need to do exactly what is suggested in the error message. And invoke java with -Djava.library.path pointing to the locations of the cplex shared module.

Something like this:

java -cp /home/apps/cplex/12.6.1/cplex/lib/cplex.jar:. -Djava.library.path=/path/to/libcplex121.so file
Strelok
  • 50,229
  • 9
  • 102
  • 115
  • i found a libcplex.a but i don't see anywhere .so , do i have to use libcplex121.so or libcplex121.a ?? – Emaneitron Jul 23 '15 at 01:37
  • If you installed and configured Cplex correctly you must have `libcplex.so` file. `-Djava.library.path` must point to the directory containing this file. Install and configure Cplex correctly. – Strelok Jul 23 '15 at 01:44
  • i found one in the opl folder and used java -cp /home/apps/cplex/12.6.1/cplex/lib/cplex.jar:. -Djava.library.path=/home/apps/cplex/12.6.1/opl/bin/x86-64_linux/libcplex1261.so memoria/bosques but didn't work either... :/ – Emaneitron Jul 23 '15 at 02:05
  • -Djava.library.path=/home/apps/cplex/12.6.1/cplex/bin/x86-64_linux/libcplex1261.so is the other one... didn't work :( – Emaneitron Jul 23 '15 at 02:12
  • Try just -Djava.library.path=/home/apps/cplex/12.6.1/cplex/bin/x86-64_linux – Strelok Jul 23 '15 at 03:06
  • I got this: -bash: -Djava.library.path=/home/apps/cplex/12.6.1/cplex/bin/x86-64_linux/libcplex1261.so: No such file or directory ...but if i do the ls of the directory it clearly appears the file in the terminal – Emaneitron Jul 23 '15 at 13:50
  • in the end the error said to put the path to the directory (and not to the file) i changed that and worked ....thanks for your help! – Emaneitron Jul 23 '15 at 14:05