When using the Gurobi Java API, you may see a java.lang.NoClassDefFoundError exception such as:
java.lang.NoClassDefFoundError: gurobi/GRBException java.lang.NoClassDefFoundError: Could not initialize class gurobi.GurobiJni
This error indicates that the Gurobi Java library (gurobi.jar) was not found within your Java classpath at the time of execution. This file is located in the lib subdirectory of the Gurobi installation.
To set the classpath for Java on Linux, you can use either:
- set the CLASSPATH environment variable or
- use the command-line option -cp or -classpath for the Java Runtime Environment.