1

I'm using Docker with the https://hub.docker.com/r/bitnami/java image. I've got my jar file aa.jar and it uses Gurobi.

I'm setting the environment variables so that Gurobi can be found.

GUROBI_HOME=/code/gurobi811/linux64
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib
GRB_LICENSE_FILE=/code/gurobi.lic
PATH=${PATH}:/opt/bitnami/java/bin:/opt/bitnami/java/lib:/opt/bitnami/java:/bin:/usr/bin/:/code/gurobi811/linux64/bin:/code/bin
JAVA_HOME=/opt/bitnami/java

When I run the code I also include gurobi.jar in the classpath

java -cp gurobi.jar -jar aa.jar evaluate

This is working to an extent. When I don't include the classpath I get the error Exception in thread "main" java.lang.NoClassDefFoundError: gurobi/GRBException. The exception is the first mention of Gurobi in the code. When I include it I get

Exception in thread "main" java.lang.NoClassDefFoundError: gurobi/GRBExpr
java_1    |     at Alg.evaluate.main(evaluate.java:44)
java_1    | Caused by: java.lang.ClassNotFoundException: gurobi.GRBExpr

I'm not sure why this isn't working as all the files should be included in the jar being included by the -cp parameter.

Also I'm only on the Gurobi academic license, so I can't go to the official Gurobi support.

2 Answers2

0

I had answered a similar question a while ago but this is what I suggested and it worked for that person .. Try doing a clean build of your project and give a try again .. You could even check the jar and may be tweak the application by removing the jar file and see if the expected jar is being reference... Also What version of the library are you using. I am not familiar with this library but similar errors could be local to one particular version and could be a known issue fixed in future versions .. Why dont you try with a different version ?

parthi
  • 101
  • 8
0

This ended up being that I needed to change the LD_LIBRARY_PATH variable

LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib:/code/gurobi811/linux64/lib

I assumed that the ${GUROBI_HOME} would put in the last part automatically but specifying it fixed the issue. I also switched from compiling a normal .jar to a runnable .jar but don't know if that helped.