Topic
4 replies Latest Post - ‏2014-04-15T08:47:57Z by DanielJunglas
Grace360
Grace360
2 Posts
ACCEPTED ANSWER

Pinned topic How to setup cplex when using Java with eclipse?

‏2010-05-19T19:44:42Z |
Question:

Dear support,
I have installed IBM ILOG license key correctly,but I can not run the program (write by java in eclipse )using CPLEX in this computer with CPLEX correctly installed in it . These programs work well in another computer with different cplex version. Can you please tell me why does this happen and how to solver such problems?
Here is the error message :

java.lang.UnsatisfiedLinkError: no cplex121 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:5358)
at ilog.cplex.CplexI.<init>(CplexI.java:525)
at ilog.cplex.IloCplex.<init>(IloCplex.java:9229)
at AgusPractice.DietPractice.main(DietPractice.java:128)

Thank you very much

Grace
Updated on 2010-05-19T22:15:36Z at 2010-05-19T22:15:36Z by Grace360
  • SystemAdmin
    SystemAdmin
    7944 Posts
    ACCEPTED ANSWER

    Re: How to setup cplex when using Java with eclipse?

    ‏2010-05-19T20:42:17Z  in response to Grace360
    Is this occurring inside Eclipse or when you try to run the compiled code (.class or .jar file) outside CPLEX? If it occurs inside CPLEX, you need to add the location of the CPLEX executable to your library entry for Eclipse (Window > Preferences > Java > Build Path > User Libraries). Click the arrow next to cplex.jar to expand it, select Native library location, and set it to point to the folder (should be under .../bin) that contains the CPLEX library (.so extension on Linux, .dll on Windows).

    If the problem occurs when running the compiled code, add the same path to the library path option in the command line (-Djava.library.path=...).

    /Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    • Grace360
      Grace360
      2 Posts
      ACCEPTED ANSWER

      Re: How to setup cplex when using Java with eclipse?

      ‏2010-05-19T22:15:36Z  in response to SystemAdmin
      Hi,Paul,

      Thank you very much.

      Grace
      • MAYMA
        MAYMA
        1 Post
        ACCEPTED ANSWER

        Re: Comment installer CPLEX pour l'utilisation de Java avec Eclipse?

        ‏2014-04-15T08:39:15Z  in response to Grace360

        Dear support, I have installed cplex.jar correctly, i introduced it in my application which developed by java in netbeans, the programs work well, but i can't resolve the problem, when i run the compiled code, i get this message: 

        ‹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:5358)
        at ilog.cplex.CplexI.<init>(CplexI.java:525)
        at ilog.cplex.IloCplex.<init>(IloCplex.java:9229)
        at ACVRP_without_y.main(ACVRP_without_y.java:317)
        java.lang.UnsatisfiedLinkError: no cplex121 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=...

        i read your answer that you say 'If the problem occurs when running the compiled code, add the same path to the library path option in the command line (-Djava.library.path=...).  ' but i don't understand how i could do that and where i found the command line

        thank you 

        • DanielJunglas
          DanielJunglas
          802 Posts
          ACCEPTED ANSWER

          Re: Comment installer CPLEX pour l'utilisation de Java avec Eclipse?

          ‏2014-04-15T08:47:57Z  in response to MAYMA

          You have to start the JVM with argument -Djava.library.path=/path/to/lib where /path/to/lib is the absolute path to the folder that contains libcplex121.so/libcplex121.dll (depending on your platform).

          I don't know netbeans so I don't know how to do that in netbeans, but this seems to explain how to do that.