The Java package for Gurobi can be obtained through our website as part of the Gurobi Optimizer. This jar file, which can be found in the "lib" directory, i.e. <installdir>/lib, facilitates the Java API, but it does not contain the libraries for our solver.
From version 10.0.3, and onwards, Java packages are also published to Maven Central, allowing package managers such as Maven, Gradle, and sbt to consume it. For each version two packages will be available via Maven Central:
- A "core" package, identical to the one distributed via the Gurobi website
- A "full" (self-contained) package which contains the solver libraries for linux64 armlinux64, win64 and macos_universal2.
When using a package manager the artifact should be specified as com.gurobi.gurobi and import statements in the code will appear as:
import com.gurobi.gurobi.*;
A pom.xml file for example, for use with Maven, would include the following specifications:
<project>
...
<dependencies>
...
<dependency>
<groupId>com.gurobi</groupId>
<artifactId>gurobi</artifactId>
<version>11.0.2</version>
</dependency>
...
</dependencies>
</project>
To use the core package the additional field <classifier>core</classifier>
must be added to the dependency specification. Since the core package does not have the solver libraries it will try to load the Gurobi version that is installed or specified with the LD_LIBRARY_PATH
environment variable. See How do I set system environment variables for Gurobi? for guidance on setting this variable.
Comments
0 comments
Article is closed for comments.