Compiling CPLEX Applications in Concert Technology

When compiling a Java program that uses ILOG CPLEX Concert Technology, you need to inform the Java compiler where to find the file cplex.jar containing the ILOG CPLEX Concert Technology class library. To do this, you add the cplex.jar file to your classpath. This is most easily done by passing the command-line option

  -classpath <path_to_cplex.jar> 

to the Java compiler javac. If you need to include other Java class libraries, you should add the corresponding jar files to the classpath as well. Ordinarily, you should also include the current directory '.' to be part of the Java classpath.

At execution time, the same classpath setting is needed. Additionally, since CPLEX is implemented via JNI, you need to instruct the Java Virtual Machine (JVM) where to find the shared library (or dynamic link library) containing the native code to be called from Java. This may be done with the command line option

  -Djava.library.path=<path_to_shared_library> 

to the java command. Note that, unlike the cplex.jar file, the shared library is system dependent; thus the exact pathname, of the location for the library to be used, differs depending on the platform you are using.

Pre-configured compilation and runtime commands are provided in the standard distribution, through the Unix makefiles and Windows "javamake" file for Nmake. However, these scripts presume a certain relative location for the files mentioned above, and for application development most users will have their source files in some other location.

Below are suggestions for establishing build procedures for your application.

  1. First check the readme.html file in the standard distribution, under the Supported Platforms heading to locate the <machine> and <libformat> entry for your Unix platform, or the compiler and library format combination for Windows.
  2. Go to the subdirectory under the examples directory where CPLEX is installed on your machine. On Unix this will be <machine>/<libformat>, and on Windows it will be <compiler>\<libformat>. This subdirectory will contain a makefile or javamake appropriate for your platform.
  3. Then use these files to compile the examples that came in the standard distribution by calling make execute_java (Unix) or nmake -f javamake execute (Windows).
  4. Carefully note the locations of the needed files, both during compilation and at run time, and convert the relative path names to absolute path names for use in your own working environment.

Previous Page: Concert Technology for Java Users Return to Top Next Page: In Case Problems Arise