Java Interface

This section will work through a simple Java example in order to illustrate the use of the Gurobi Java interface. The example builds a model, optimizes it, and outputs the optimal objective value. This section assumes that you are already familiar with the Java programming language. If not, a variety of books and websites are available for learning the language (for example, the online Java tutorials).

If you are using an integrated development environment like Eclipse®, we recommend that you import the file <installdir>/lib/gurobi-javadoc.jar, which contains Javadoc documentation for the Gurobi Java interface.

Our example optimizes the following model:

maximize x + y + 2 z    
subject to x + 2 y + 3 z <span>$</span>\leq<span>$</span> 4
  x + y     <span>$</span>\geq<span>$</span> 1
  x, y, z binary  
Note that this is the same model that was modeled and optimized in the C Interface section.



Subsections