Exception in thread “main” java.lang.UnsatisfiedLinkError: no GurobiJni56 in java.library.path

瘦欲@ 提交于 2019-12-11 05:19:32

问题


First of all, I am new to Java programming and please excuse me for any wrong use of terms or for overseeing obvious mistakes. I am using OS X Yosemite on a MacBook Pro, and are coding Java in Eclipse.

I encounter the exception given in the title when I'm trying to run my program. Here, Gurobi is a solver for optimization problems and is downloaded from http://www.gurobi.com/. The weird thing is that my program was working the other day, but then it suddenly ceased to work. Any regular programs that does not use anything from the gurobi.*; package runs just fine. Importing gurobi.*; also works fine in my test program, so it exists.

Googling the error tells me there's something wrong with the path for finding the Gurobi library. Has anyone encountered the same problem and is familiar with a solution? As I said, I am new to Java and have no clue how to set up the preferences right. Also, the Gurobi FAQ (http://www.gurobi.com/resources/faqs) says there is no need to do any special configuration with the default installation of Gurobi Optimizer in order to use Gurobi in an Eclipse Java project on OS X.

If anyone know how to adjust these things on OS X and also may have used the Gurobi software for Eclipse Java on OS X, it would have been very helpful!

Here's the whole console message I encounter when running the program:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no GurobiJni56 in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1764)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1044)
    at gurobi.GurobiJni.<clinit>(GurobiJni.java:193)
    at gurobi.GRBEnv.<init>(GRBEnv.java:16)
    at gurobi.GRBEnv.<init>(GRBEnv.java:11)
    at Model.main(Model.java:426)

Thank you in advance! Let me know if the information I have provided is not sufficient to answer my issue.

Henrik


回答1:


Try to add the directory that contains the library libGurobiJni56.jnilib to the java.library.path property.

You can do it by adding this to the javavm arguments:

-Djava.library.path=/path/to/libGurobiJni55/

Or in eclipse like in this question:

How to set the java.library.path from Eclipse



来源:https://stackoverflow.com/questions/26761348/exception-in-thread-main-java-lang-unsatisfiedlinkerror-no-gurobijni56-in-jav

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!