【发布时间】:2020-06-19 11:09:09
【问题描述】:
我正在尝试在具有 or-tools 中最新的 maven 支持的 IDE 中运行示例。在 cmake 构建完成后(来自here 的指令)我可以在我的 .m2 文件夹中看到 jar 文件。我在我的项目中添加了以下依赖项
<dependency>
<groupId>com.google.ortools</groupId>
<artifactId>ortools-java</artifactId>
<version>7.7.7810</version>
</dependency>
编译成功,但在运行程序时抛出以下错误
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniortools in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.walmartlabs.services.core.engine.ortools.OrToolSolver.<clinit>(OrToolSolver.java:13)
不应该添加依赖就足够了为什么它需要下面的外部库示例程序。
public class OrToolSolver {
static {
System.loadLibrary("jniortools");
}
public static void main(String[] args) {
// Create the linear solver with the CBC backend.
MPSolver solver = new MPSolver("SimpleMipProgram", MPSolver.OptimizationProblemType.CBC_MIXED_INTEGER_PROGRAMMING);
}
我可能遗漏了一些明显的东西。
【问题讨论】:
-
我相信你需要告诉 maven 在哪里加载 jni 库。命令行上的类似 java.library.path 的东西。
标签: or-tools