Topic
  • 10 replies
  • Latest Post - ‏2016-06-23T10:15:04Z by DanielJunglas
Grace360
Grace360
2 Posts

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
    7929 Posts

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

    ‏2010-05-19T20:42:17Z  
    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

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

    ‏2010-05-19T22:15:36Z  
    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)
    Hi,Paul,

    Thank you very much.

    Grace
  • MAYMA
    MAYMA
    1 Post

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

    ‏2014-04-15T08:39:15Z  
    • Grace360
    • ‏2010-05-19T22:15:36Z
    Hi,Paul,

    Thank you very much.

    Grace

    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
    2214 Posts

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

    ‏2014-04-15T08:47:57Z  
    • MAYMA
    • ‏2014-04-15T08:39:15Z

    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 

    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.

  • Steamera
    Steamera
    3 Posts

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

    ‏2016-06-20T14:24:13Z  

    Hello,

     

    
    I have a similar problem for a grails application running on a tomcat server.
    The application was developed under windows on the IDE IntelliJ Idea.
    
    The cplex.jar is in the libraries folder 
    
    I inserted in the VM options (my "libcplex1260.so" file is in this folder)
    :
    
    -Djava.library.path=/opt/ibm/ILOG/CPLEX_Studio126/cplex/bin/x86-64_linux/ 
    
    But I got the error :
    
    

     

    .

    Caused by UnsatisfiedLinkError: ilog.cplex.Cplex.CPXopenCPLEX([I)J
    ->> 6594 | init      in ilog.cplex.CplexI
    
    
    CPLEX is installed on the Windows PC and on the PC linux (with tomcat) .
    The application works well on windows when I execut it with IntelliJ Idea but on linux 
    with the exported application I have the error. 
    
    On the linux pc I tested CPLEX from the command line by running the Java CPLEX tests
     as explained on the IBM website. CPLEX works well.
    I do not understand where the problem is.
    
    How to solve UnsatisfiedLinkError message ?
    

    bests regards

    Updated on 2016-06-20T14:28:18Z at 2016-06-20T14:28:18Z by Steamera
  • DanielJunglas
    DanielJunglas
    2214 Posts

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

    ‏2016-06-20T14:51:44Z  
    • Steamera
    • ‏2016-06-20T14:24:13Z

    Hello,

     

    <pre class="tw-data-text vk_txt tw-ta tw-text-small" data-fulltext="" data-placeholder="Traduction" dir="ltr" style="text-align: left; height: 192px;"> I have a similar problem for a grails application running on a tomcat server. The application was developed under windows on the IDE IntelliJ Idea. The cplex.jar is in the libraries folder I inserted in the VM options (my "libcplex1260.so" file is in this folder) : -Djava.library.path=/opt/ibm/ILOG/CPLEX_Studio126/cplex/bin/x86-64_linux/ But I got the error : </pre>

     

    .

    <pre class="stack" dir="ltr">Caused by UnsatisfiedLinkError: ilog.cplex.Cplex.CPXopenCPLEX([I)J ->> 6594 | init in ilog.cplex.CplexI </pre> <pre class="stack" dir="ltr"> CPLEX is installed on the Windows PC and on the PC linux (with tomcat) . The application works well on windows when I execut it with IntelliJ Idea but on linux with the exported application I have the error. On the linux pc I tested CPLEX from the command line by running the Java CPLEX tests as explained on the IBM website. CPLEX works well. I do not understand where the problem is. How to solve UnsatisfiedLinkError message ? </pre>

    bests regards

    Is this the only error you see? Do you see any errors before? Like errors that would suggest that the .so could not be loaded or found. Are you by any chance mixing a 32bit Java virtual machine with 64bit CPLEX library?

  • Steamera
    Steamera
    3 Posts

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

    ‏2016-06-21T07:02:31Z  
    
    Hello
    
    Thank you for this quick response.
    
    Here is the full error message
    
        Line | Method
    ->> 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    745 | run . . . in java.lang.Thread
    
    Caused by ControllerExecutionException: Runtime error executing action
    ->> 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    745 | run . . . in java.lang.Thread
    
    Caused by InvocationTargetException: null
    ->> 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    745 | run . . . in java.lang.Thread
    
    Caused by UnsatisfiedLinkError: ilog.cplex.Cplex.CPXopenCPLEX([I)J
    ->> 6594 | init      in ilog.cplex.CplexI
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    |    629 | <init>    in     ''
    |   11067 | <init> .  in ilog.cplex.IloCplex
    |   11082 | <init>    in     ''
    |     94 | save . .  in agriplan.APProjectController
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    745 | run       in java.lang.Thread
    
  • DanielJunglas
    DanielJunglas
    2214 Posts

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

    ‏2016-06-21T07:21:01Z  
    • Steamera
    • ‏2016-06-21T07:02:31Z
    <pre class="tw-data-text vk_txt tw-ta tw-text-small" data-fulltext="" data-placeholder="Traduction" dir="ltr" id="tw-target-text" style="text-align: left; height: 120px;"> Hello Thank you for this quick response. Here is the full error message </pre> <pre class="stack" dir="ltr"> Line | Method ->> 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run . . . in java.lang.Thread Caused by ControllerExecutionException: Runtime error executing action ->> 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run . . . in java.lang.Thread Caused by InvocationTargetException: null ->> 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run . . . in java.lang.Thread Caused by UnsatisfiedLinkError: ilog.cplex.Cplex.CPXopenCPLEX([I)J ->> 6594 | init in ilog.cplex.CplexI - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 629 | <init> in '' | 11067 | <init> . in ilog.cplex.IloCplex | 11082 | <init> in '' | 94 | save . . in agriplan.APProjectController | 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor | 615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker ^ 745 | run in java.lang.Thread </pre>

    I am wondering whether you don't see any other output from CPLEX before that error. For example, if CPLEX cannot load the native library it should print something like this to stdout:

    <exception message here>
    java.library.path must point to the directory containing the CPLEX shared library
    try invoking java with java -Djava.library.path=...

    Do you see this anywhere? Or do you swallow/redirect messages on stdout somehow?

    Can you try if the problem persists if you set environment LD_LIBRARY_PATH=/opt/ibm/ILOG/CPLEX_Studio126/cplex/bin/x86-64_linux before starting your application? Also, can you print System.getProperty("java.library.path") and System.getenv("LD_LIBRARY_PATH") from your application to make sure the settings actually make it to your app?

  • Steamera
    Steamera
    3 Posts

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

    ‏2016-06-23T09:05:53Z  

    Thank you Daniel It works !

    
    You were right, it was a problem with LD_LIBRARY_PATH
    So I made a symbolic link to the libcplex1260.so in the /usr/lib folder
    
    cd /usr/lib
    ln -s /opt/ibm/ILOG/CPLEX_Studio126/cplex/bin/x86-64_linux/libcplex1260.so .
    
    Thank you again
    
    

     

  • DanielJunglas
    DanielJunglas
    2214 Posts

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

    ‏2016-06-23T10:15:04Z  
    • Steamera
    • ‏2016-06-23T09:05:53Z

    Thank you Daniel It works !

    <pre class="tw-data-text vk_txt tw-ta tw-text-small" data-fulltext="" data-placeholder="Traduction" dir="ltr" style="text-align: left; height: 216px;"> You were right, it was a problem with LD_LIBRARY_PATH So I made a symbolic link to the libcplex1260.so in the /usr/lib folder cd /usr/lib ln -s /opt/ibm/ILOG/CPLEX_Studio126/cplex/bin/x86-64_linux/libcplex1260.so . Thank you again </pre>

     

    Well, if this works then something was wrong with your java.library.path before. Either it pointed to the wrong place or its value did not properly propagate to the context in which the CPLEX classes are loaded.