Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

CPLEX Java API compiles with `jar` file in Windows but not DLL

  • 1.  CPLEX Java API compiles with `jar` file in Windows but not DLL

    Posted Thu September 10, 2020 05:43 PM

    Upfront disclosure: I am not a Java programmer, but am slowly picking it up.

    I am following https://kunlei.github.io/cplex/cplex-java-setup to compile an example that uses CPLEX's Java API. I'm on Windows 10, but because of my familiarity with Cygwin's Bash and Gvim, I use them to get around and manipulate files. I may complement them with an IDE down the road. For now, the compiler is invoked using:

    javac -Xstdout mk.out \

    -classpath \

    'c:/Program Files/IBM/ILOG/CPLEX_Studio129/cplex/lib/cplex.jar' \

    TestSetup.java

    For the JDK, I have AdoptOpenJDK's OpenJDK version 11.0.8.10 with JVM Openj9.

    While the above compiles, I ran across documentation that suggests that it is the wrong `classpath` file. I'm not using Eclipse, but the following Eclipse page in the CPLEX documentation says that a Windows environment should use a *.dll file rather than a *.jar file:

    CPLEX -> Getting Started with CPLEX

    -> Setting up CPLEX

    -> Setting up Eclipse for the Java API of CPLEX

    The most promising-looking candidate from my search of the CPLEX installation directory is:

    'c:/Program Files/IBM/ILOG/CPLEX_Studio129/cplex/bin/x64_win64/cplex1290.dll'

    However, if I use this instead of the *.jar file, I a tsunami of errors pertaining to nonexistence of classes. In fact, I get the same errors if I specify an arbitrary non-existent file, so the *.dll file is obviously "not working".

    Why would a *.jar file work on Windows, but a *.dll file not? I'm uneasy forging ahead as if all is fine when it clearly contradicts what is in the documentation.






    #DecisionOptimization
    #Support
    #SupportMigration


  • 2.  RE: CPLEX Java API compiles with `jar` file in Windows but not DLL
    Best Answer

    Posted Fri September 11, 2020 12:53 AM

    This one will be for the Java newbies, as I'm sure that it is well-known: The *.jar file is for the -classpath argument in both `java` and `javac` commands, while the *.dll file is the "native library" folder path for the -Djava.library.path argument of `javac`. Multiple paths are separated by semicolons.






    #DecisionOptimization
    #Support
    #SupportMigration


  • 3.  RE: CPLEX Java API compiles with `jar` file in Windows but not DLL
    Best Answer

    Posted Fri September 11, 2020 12:55 AM

    And for added context, "native" means a library containing functionality that is native to the host machine on which the JVM is executing, not native the JDK. Usage of native libraries represent non-portable dependencies on the specific machine.






    #DecisionOptimization
    #Support
    #SupportMigration