我正在使用Java的MATLAB Engine API,到目前为止,诸如eval和feval函数之类的基础知识都可以正常工作。我什至用这些绘制了直方图。但是PutVariable方法使我拥有“ EXCEPTION_ACCESS_VIOLATION”。
代码为:
package connecter;
import java.util.*;
import java.util.concurrent.ExecutionException;
import com.mathworks.engine.*;
public class MainClass {
public static void main(String[] args) throws IllegalArgumentException, IllegalStateException, InterruptedException, MatlabExecutionException, MatlabSyntaxException, ExecutionException {
MatlabEngine matEng = MatlabEngine.startMatlab();
matEng.putVariable("x", 3.0);
}
控制台为我提供了以下内容:
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000001b224d20b95, pid=1904, tid=8768
#
# JRE version: Java(TM) SE Runtime Environment (12.0.2+10) (build 12.0.2+10)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (12.0.2+10, mixed mode, sharing, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# v ~StubRoutines::atomic_add_long
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# [Filepath]\hs_err_pid1904.log
Could not load hsdis-amd64.dll; library not loadable; PrintAssembly is disabled
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
到目前为止,我已经搜索了无数线程,但到目前为止,没有任何结果。我正在使用JavaSE-12,而MATLAB是R2019b。
您做对了。这是Matlab和/或JDK中的错误。您在这里可以做的不多。与MathWorks和您的JDK供应商的支持人员联系,并让他们知道发生了什么,然后与您的IT部门联系,以查看您是否有一个奇怪的机器配置,可能使他们混乱。
并尝试在不同的JDK上运行,例如较低的主要版本,例如JDK8。Matlab使用旧的JDK版本,因此更有可能经过测试并与之对抗。