Topic
8 replies Latest Post - ‏2012-05-09T05:47:41Z by SystemAdmin
SystemAdmin
SystemAdmin
754 Posts
ACCEPTED ANSWER

Pinned topic java and cplex

‏2012-03-06T08:30:31Z |
Hello
I have a problem with adding cplex.jar to my java project. I installed the new Lion OX and I used to add the cplex.jar to my java projects easily when I had snow leopard, but now when I add the jar file and run the program I get the following error:

java.lang.UnsatisfiedLinkError: no cplex124 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.<init>(CplexI.java:611)
at ilog.cplex.IloCplex.<init>(IloCplex.java:10384)
at test.main(test.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

I even installed the cplex 12.4 and I use intelidea as an IDE for my java. Do you have any ideas?
Updated on 2012-05-09T05:47:41Z at 2012-05-09T05:47:41Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    754 Posts
    ACCEPTED ANSWER

    Re: java and cplex

    ‏2012-03-06T09:33:19Z  in response to SystemAdmin
    What is the value of your java.library.path property? Does it point to the folder that contains the cplex124 shared object?
    • SystemAdmin
      SystemAdmin
      754 Posts
      ACCEPTED ANSWER

      Re: java and cplex

      ‏2012-03-06T18:49:14Z  in response to SystemAdmin
      yes, after I added the cplex.jar, I expand the arrow on the left side and set the native location library to the cplex lib path
      • SystemAdmin
        SystemAdmin
        754 Posts
        ACCEPTED ANSWER

        Re: java and cplex

        ‏2012-03-07T08:04:02Z  in response to SystemAdmin
        Do the Java examples shipped with CPLEX work?
        To test this do (replace /path/to/COS/installation, PORT and SYSLIB appropriately)
        
        cd /path/to/COS/installation/cplex/examples/PORT/SYSLIB make execute_java
        

        Does this work? Is this able to run the Java examples? Or do you get the same error message?
  • MarioWinter
    MarioWinter
    2 Posts
    ACCEPTED ANSWER

    Re: java and cplex

    ‏2012-05-08T06:33:40Z  in response to SystemAdmin
    I've got the same problems on Mac OS. I even can't locate the shared library cplex124.so in any of the ILOG installation directories. Where is it or where should it be???
    • SystemAdmin
      SystemAdmin
      754 Posts
      ACCEPTED ANSWER

      Re: java and cplex

      ‏2012-05-08T06:39:38Z  in response to MarioWinter
      On MacOS the extension for the shared library is '.jnilib' instead of '.so'. It should be in directory INSTALLROOT/cplex/bin/x86-64_darwin9_gcc4.0 (or INSTALLROOT/cplex/bin/x86_darwin9_gcc4.0 for 32bit systems).
      • MarioWinter
        MarioWinter
        2 Posts
        ACCEPTED ANSWER

        Re: java and cplex

        ‏2012-05-08T13:31:22Z  in response to SystemAdmin
        Thanx, found it! The delivered make worked anyway, and the java examples run from the shell. Unfortunately, I dont get them compiled and executed with eclipse - the cplex124 lib not found error still exists. Maybe it's a configuration problem with jre and 32/64 bit or the eclipse internal compiler doesn't get the calls right?
        • SystemAdmin
          SystemAdmin
          754 Posts
          ACCEPTED ANSWER

          Re: java and cplex

          ‏2012-05-09T05:46:32Z  in response to MarioWinter
          Did you set the java.library.path properly? In the run configuration you need a VM argument like
          
          -Djava.library.path=/path/to/folder/with/lib
          

          It may be that the virtual machine started by eclipse is different from the virtual machine you use on the command line. Maybe try the 32bit version of the CPLEX library and also the 64bit version of it.
        • SystemAdmin
          SystemAdmin
          754 Posts
          ACCEPTED ANSWER

          Re: java and cplex

          ‏2012-05-09T05:47:41Z  in response to MarioWinter
          By the way, there is a technote/FAQ about how to setup eclipse with CPLEX here.