ILOG CPLEX 11.0 Getting Started > Tutorials > Concert Technology Tutorial for Java Users > The Anatomy of an ILOG Concert Technology Java Application |
The Anatomy of an ILOG Concert Technology Java Application |
INDEX PREVIOUS NEXT |
To use the ILOG CPLEX Java interfaces, you need to import the appropriate packages into your application. This is done with the lines:
import ilog.concert.*; import ilog.cplex.*;
As for every Java application, an ILOG CPLEX application is implemented as a method of a class. In this discussion, the method will be the static main
method. The first task is to create an IloCplex
object. It is used to create all the modeling objects needed to represent the model. For example, an integer variable with bounds 0 and 10 is created by calling cplex.intVar(0, 10)
, where cplex
is the IloCplex
object.
Since Java error handling in ILOG CPLEX uses exceptions, you should include the ILOG Concert Technology part of an application in a try
/catch
statement. All the exceptions thrown by any ILOG Concert Technology method are derived from IloException
. Thus IloException
should be caught in the catch
statement.
In summary, here is the structure of a Java application that calls ILOG CPLEX:
import ilog.concert.*; import ilog.cplex.*; static public class Application { static public main(String[] args) { try { IloCplex cplex = new IloCplex(); // create model and solve it } catch (IloException e) { System.err.println("Concert exception caught: " + e); } } }
Copyright © 1987-2007 ILOG S.A. All rights reserved. Legal terms. | PREVIOUS NEXT |