IBM Support

Configuring the Eclipse Java IDE to use CPLEX libraries

Question & Answer


Question

How do I configure the Eclipse Java IDE to use CPLEX libraries?

Cause

To specify the configuration details required to connect the Eclipse Java IDE with CPLEX libraries.

Answer

Perform the following steps to configure Eclipse with CPLEX:

1. If you are creating a new Java project
File -> New -> Java project
Else, import the existing project into your workspace
File -> Import -> Expand on 'General' -> Select 'Existing Projects into Workspace'

2. Create source (class) files as needed. To add a new class to the project,
Right click on the source folder (src) -> New -> Class, specify a name, change the
properties like package, modifiers, automatic stubs etc as required, and then click 'Finish'.
To add an existing java file to the project, simply drag and drop the .java file into the 'src'
folder of the project. Sample java programs can be found under <cplex>\examples\src\java
directory.

3. Include the CPLEX jar in the project
a) Project -> Properties -> Java Build Path -> Libraries tab ->
b) Click the 'Add External JARs ...' button and point to cplex.jar
file (found under the <CPLEX>/lib directory)

4. Run Configuration setup
a) Run -> Run Configurations ... -> Java Application
b) Right click to select 'New' if no Run Configuration exists or select the one
which you would like to configure.
c) On the 'Main' tab select your main class (the class containing
the main() function that you want to run).
d) On the 'Arguments' tab add the following to 'VM arguments' section
-Djava.library.path=<path_to_so_or_dll_or_jnilib>
where <path_to_so_or_dll_or_jnilib> is the directory that contains the
libcplex<version>.so (Linux) or libcplex<version>.jnilib (Mac) or cplex<version>.dll (Windows) file
found by default under the <CPLEX_installation_dir>/bin/<port> directory.
e) If the PATH environment variable is globally defined and includes CPLEX's
.dll or .so or .jnilib (platform dependant) files, then the previous step is not required.
f) This step is required only if you are using CPLEX 12.1 or an earlier version.
If CPLEX's license path is not globally defined under the ILOG_LICENSE_FILE
environment variable, then you can do so in the 'Environment' tab. Click 'New'
and enter ILOG_LICENSE_FILE as the Name and <license_file_location> as the
Value. The <license_file_location> needs to specify the license file name as well and not
just the directory it is present under.

5. You should now be able to run the program.


Note: The above contents have been added to CPLEX documentation.

[{"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF022","label":"OS X"},{"code":"PF033","label":"Windows"}],"Version":"9.2;9.1.3;9.1.2;9.1;9.0;8.1;8.0;7.5;7.1;7.0;6.6;12.5.0.1;12.5;12.4;12.3;12.2;12.1;12.0;11.2.1;11.2;11.1.1;11.1;11.0.1;11.0;10.3;10.2.1;10.2;10.1.1;10.1;10.0","Edition":"All Editions","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSSA5P","label":"IBM ILOG CPLEX Optimization Studio"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF017","label":"Mac OS"},{"code":"PF033","label":"Windows"}],"Version":"12.5.1;12.5.0.1;12.5;12.4;12.3;12.2.0.1;12.2","Edition":"All Editions","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21449776