从Java执行MATLAB脚本会产生EXCEPTION_ACCESS_VIOLATION错误

时间:2018-12-20 21:49:10

标签: java eclipse matlab

我正在尝试使用Eclipse从Java调用MATLAB函数。我正在使用MATLAB R2018b(试用版),JDK 11.0.1和Eclipse 2018-09。 MATLAB和Eclipse均为64位版本。我在Windows 64位计算机上。

根据此示例,我正在使用MatlabEnginehttps://uk.mathworks.com/help/matlab/matlab_external/execute-matlab-functions-from-java.html

如果我尝试通过我的main方法运行以下代码段(从上面的链接中逐字复制)

MatlabEngine eng = MatlabEngine.startMatlab();
double[] a = {2.0, 4.0, 6.0};
double[] roots = eng.feval("sqrt", a);
for (double e : roots) {
    System.out.println(e);
}
eng.close(); 

...我收到以下错误:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000005700000b95, pid=11028, tid=11252
#
# JRE version: Java(TM) SE Runtime Environment (11.0.1+13) (build 11.0.1+13-LTS)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (11.0.1+13-LTS, mixed mode, 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:
# F:\research\software\code\eclipse_workspace\tests\hs_err_pid11028.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
#

我尝试了Google搜索错误消息,但无济于事。这里发生了什么?

1 个答案:

答案 0 :(得分:1)

我最近遇到了这个确切的错误(但使用 Matlab R2020b)。对于仍然感兴趣的任何人,将运行时 JRE 从 JDK11 切换到 JDK-8.0.275.1 解决了问题。