UnsatisfiedLinkError: no GurobiJni45 in java.library.path

601 views
Skip to first unread message

Kasper T

unread,
Nov 10, 2011, 3:34:53 AM11/10/11
to Gurobi Optimization
Hi
I have a small problem.
I am trying to run the lp.java example from the website using Eclipse.
But when I do I get the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no
GurobiJni45 in java.library.path

I've installed Gurobi according to the guide on the website, and I've
added gurobi.jar to my project, what can be causing this error?
The interactive shell works fine, so I'm assuming that gurobi is
installed correctly.

Best regards,
Kasper

Greg Glockner

unread,
Nov 10, 2011, 8:58:45 AM11/10/11
to gur...@googlegroups.com
Eclipse instructions can be found in FAQ 23:

http://www.gurobi.com/html/techfaq.html

Message has been deleted

Luciana Assis

unread,
Nov 28, 2018, 2:36:39 PM11/28/18
to Gurobi Optimization
Dear Greg Giockner,

I have the same problem with the gurobi 810 and Netbeans 8.2 (JVM 1.8).
I tried to open the link but I could not.

*** Here is the returned error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no GurobiJni81 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at gurobi.GurobiJni.<clinit>(GurobiJni.java:261)
    at gurobi.GRBEnv.<init>(GRBEnv.java:43)
    at testegurobi.TesteGurobi.main(TesteGurobi.java:15)
/home/decom/.cache/netbeans/8.2/executor-snippets/run.xml:53: Java returned: 1
FALHA NA CONSTRUÇÃO (tempo total: 0 segundos)

*** The files of the gurobi810/linux64/lib directory:

/home/decom/gurobi810/linux64/lib/python2.7
/home/decom/gurobi810/linux64/lib/python2.7_utf16
/home/decom/gurobi810/linux64/lib/python2.7_utf32
/home/decom/gurobi810/linux64/lib/python3.5_utf32
/home/decom/gurobi810/linux64/lib/python3.6_utf32
/home/decom/gurobi810/linux64/lib/python3.7_utf32
/home/decom/gurobi810/linux64/lib/gurobi.jar
/home/decom/gurobi810/linux64/lib/gurobi.py
/home/decom/gurobi810/linux64/lib/gurobi81.netstandard20.dll
/home/decom/gurobi810/linux64/lib/gurobi81.netstandard20.xml
/home/decom/gurobi810/linux64/lib/gurobi-javadoc.jar
/home/decom/gurobi810/linux64/lib/libgurobi.so.8.1.0
/home/decom/gurobi810/linux64/lib/libgurobi81.so
/home/decom/gurobi810/linux64/lib/libgurobi81_light.so
/home/decom/gurobi810/linux64/lib/libgurobi_c++.a
/home/decom/gurobi810/linux64/lib/libgurobi_g++4.2.a
/home/decom/gurobi810/linux64/lib/libgurobi_g++5.2.a
/home/decom/gurobi810/linux64/lib/libGurobiJni81.so
/home/decom/gurobi810/linux64/lib/rootcert.pem


*** My code:

package testegurobi;

import gurobi.*;

public class TesteGurobi {
  public static void main(String[] args) {
   
    System.setProperty("java.library.path", "/home/decom/gurobi810/linux64/lib/libGurobiJni81.so");

    try {
      GRBEnv    env   = new GRBEnv("mip1.log");
      GRBModel  model = new GRBModel(env);

      // Create variables

      GRBVar x = model.addVar(0.0, 1.0, 0.0, GRB.BINARY, "x");
      GRBVar y = model.addVar(0.0, 1.0, 0.0, GRB.BINARY, "y");
      GRBVar z = model.addVar(0.0, 1.0, 0.0, GRB.BINARY, "z");

      // Set objective: maximize x + y + 2 z

      GRBLinExpr expr = new GRBLinExpr();
      expr.addTerm(1.0, x); expr.addTerm(1.0, y); expr.addTerm(2.0, z);
      model.setObjective(expr, GRB.MAXIMIZE);

      // Add constraint: x + 2 y + 3 z <= 4

      expr = new GRBLinExpr();
      expr.addTerm(1.0, x); expr.addTerm(2.0, y); expr.addTerm(3.0, z);
      model.addConstr(expr, GRB.LESS_EQUAL, 4.0, "c0");

      // Add constraint: x + y >= 1

      expr = new GRBLinExpr();
      expr.addTerm(1.0, x); expr.addTerm(1.0, y);
      model.addConstr(expr, GRB.GREATER_EQUAL, 1.0, "c1");

      // Optimize model

      model.optimize();

      System.out.println(x.get(GRB.StringAttr.VarName)
                         + " " +x.get(GRB.DoubleAttr.X));
      System.out.println(y.get(GRB.StringAttr.VarName)
                         + " " +y.get(GRB.DoubleAttr.X));
      System.out.println(z.get(GRB.StringAttr.VarName)
                         + " " +z.get(GRB.DoubleAttr.X));

      System.out.println("Obj: " + model.get(GRB.DoubleAttr.ObjVal));

      // Dispose of model and environment

      model.dispose();
      env.dispose();

    } catch (GRBException e) {
      System.out.println("Error code: " + e.getErrorCode() + ". " +
                         e.getMessage());
    }
  }
}

* Notice that I'm setting the java.library.path.

System.setProperty("library.java.path", "/home/decom/gurobi810/linux64/lib/libGurobiJni81.so");

* I've tried it in other ways:

System.setProperty("library.java.path", "/home/decom/gurobi810/linux64/lib/");
System.setProperty("library.java.path", "/home/decom/gurobi810/linux64/lib/libgurobi81.so");


*** I include gurobi.jar in the library

Libraries -> Include JAR/Folder




Can you help me?

Best regards,

Luciana
Reply all
Reply to author
Forward
Message has been deleted
0 new messages