Java JBoss Fatal error: cannot find the required native library named JLinkNativeLibrary
Java JBoss Fatal error: cannot find the required native library named JLinkNativeLibrary
我正在尝试使用 JBoss 的 Java Web 应用程序使用 Wolfram Mathematica 内核。
这是主菜 Class。
public class Main {
static KernelLink ml;
static KernelLink ml2;
public Main(){
String path = "-linkmode launch -linkname 'C:/Program Files/Wolfram Research/Mathematica/9.0/MathKernel.exe'";
try {
ml = MathLinkFactory.createKernelLink(path);// подключаем ядро
ml.setComplexClass(MyComplex.class);
System.out.println(ml.getComplexClass());
ml.discardAnswer();
ml.evaluate("<<hexagon.m");
ml.discardAnswer();
}
catch (Exception e){
System.out.println(e.toString());
}
}
}
当我在 Servlet 中初始化主对象时出现错误。
21:30:59,520 ERROR [stderr] (http-/127.0.0.1:8080-2) Fatal error: cannot find the required native library named JLinkNativeLibrary.
21:30:59,520 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/WEbTest_war_exploded].[jsp]] (http-/127.0.0.1:8080-2) JBWEB000236: Servlet.service() for servlet jsp threw exception: java.lang.UnsatisfiedLinkError: com.wolfram.jlink.NativeLink.MLOpenString(Ljava/lang/String;[Ljava/lang/String;)J
at com.wolfram.jlink.NativeLink.MLOpenString(Native Method) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.NativeLink.<init>(NativeLink.java:117) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createMathLink0(MathLinkFactory.java:281) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createMathLink(MathLinkFactory.java:194) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createKernelLink0(MathLinkFactory.java:171) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createKernelLink(MathLinkFactory.java:65) [JLink.jar:4.4.0 January 24 2013]
at kostya.Main.<init>(Main.java:21)
该错误表示加载本机库时出现问题。 Java 有一个加载本机库的协议,这些库是 Windows 中的 .DLL 文件。它很可能是使用字符串中的显式路径启动应用程序,然后无法加载某些 DLL 以与之通信。
确保Java可以看到包含DLL的目录(尝试将其添加到系统PATH并先重新启动服务器):
https://www.chilkatsoft.com/java-loadLibrary-Windows.asp
我正在尝试使用 JBoss 的 Java Web 应用程序使用 Wolfram Mathematica 内核。
这是主菜 Class。
public class Main {
static KernelLink ml;
static KernelLink ml2;
public Main(){
String path = "-linkmode launch -linkname 'C:/Program Files/Wolfram Research/Mathematica/9.0/MathKernel.exe'";
try {
ml = MathLinkFactory.createKernelLink(path);// подключаем ядро
ml.setComplexClass(MyComplex.class);
System.out.println(ml.getComplexClass());
ml.discardAnswer();
ml.evaluate("<<hexagon.m");
ml.discardAnswer();
}
catch (Exception e){
System.out.println(e.toString());
}
}
}
当我在 Servlet 中初始化主对象时出现错误。
21:30:59,520 ERROR [stderr] (http-/127.0.0.1:8080-2) Fatal error: cannot find the required native library named JLinkNativeLibrary.
21:30:59,520 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/WEbTest_war_exploded].[jsp]] (http-/127.0.0.1:8080-2) JBWEB000236: Servlet.service() for servlet jsp threw exception: java.lang.UnsatisfiedLinkError: com.wolfram.jlink.NativeLink.MLOpenString(Ljava/lang/String;[Ljava/lang/String;)J
at com.wolfram.jlink.NativeLink.MLOpenString(Native Method) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.NativeLink.<init>(NativeLink.java:117) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createMathLink0(MathLinkFactory.java:281) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createMathLink(MathLinkFactory.java:194) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createKernelLink0(MathLinkFactory.java:171) [JLink.jar:4.4.0 January 24 2013]
at com.wolfram.jlink.MathLinkFactory.createKernelLink(MathLinkFactory.java:65) [JLink.jar:4.4.0 January 24 2013]
at kostya.Main.<init>(Main.java:21)
该错误表示加载本机库时出现问题。 Java 有一个加载本机库的协议,这些库是 Windows 中的 .DLL 文件。它很可能是使用字符串中的显式路径启动应用程序,然后无法加载某些 DLL 以与之通信。
确保Java可以看到包含DLL的目录(尝试将其添加到系统PATH并先重新启动服务器): https://www.chilkatsoft.com/java-loadLibrary-Windows.asp