首页 > 解决方案 > 在使用 Matlab 中的库编译器打包的 java 中运行 Matlab 代码时出现库错误

问题描述

我已经使用“deploytool”命令将 MATLAB 代码编译为 Java 包。在 Java 中使用库时,我收到错误,因为找不到库,如下所示。

我使用的是 Java 1.8.0_144,64 位,MATLAB 是 64 位,用于运行库的 java 也是 64 位。我在 intellij 设置的库部分中包含了 JavaBuilder.jar 和我的 MATLAB jar。我还在资源、类路径中加载“mclmcrrt9_4.dll”文件,也通过使用加载它 System.loadLibrary("mclmcrrt9_4");

关于此方法或将 MATLABcode 转换为 java 的任何其他方法的任何帮助都是有帮助的

错误:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.UnsatisfiedLinkError: Failed to find the required library mclmcrrt9_4.dll on java.library.path.
This library is typically installed along with MATLAB or the MATLAB Runtime. Its absence may indicate an issue with that installation or 
the current path configuration, or a mismatch with the architecture of the Java interpreter on the path.
MATLAB Runtime version this component is attempting to use: 9.4.
Java interpreter architecture: win64.

标签: javamatlab

解决方案


推荐阅读