java matlab 混合编程 Failed to find the required library mclmcrrt9_2.dll on java.library.path.
问题描述:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to find the required library mclmcrrt9_2.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.2. Java interpreter architecture: win64.
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ProxyLibraryDir.get(MCRConfiguration.java:324) at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ProxyLibraryDir.<clinit>(MCRConfiguration.java:334) at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration.getProxyLibraryDir(MCRConfiguration.java:339) at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$MCRRoot.get(MCRConfiguration.java:64) at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$MCRRoot.<clinit>(MCRConfiguration.java:76) at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration.getMCRRoot(MCRConfiguration.java:81) at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ModuleDir.<clinit>(MCRConfiguration.java:53) at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration.getModuleDir(MCRConfiguration.java:58) at com.mathworks.toolbox.javabuilder.internal.MWMCR.<clinit>(MWMCR.java:1699) at nsgaii.NsgaiiMCRFactory.newInstance(NsgaiiMCRFactory.java:55) at nsgaii.NsgaiiMCRFactory.newInstance(NsgaiiMCRFactory.java:66) at nsgaii.NsgaiiOperator.<init>(NsgaiiOperator.java:167) at optimization.algorithm.nsgaii.NSGAII.main(NSGAII.java:33)
问题分析:
未安装matlab runtime运行环境,或运行环境版本不匹配
问题解决:
1. 安装MCR环境(E:\MATLAB\R2017a\toolbox\compiler\deploy\win64\MCRInstaller.exe)
配置 path
C:\Program Files\MATLAB\MATLAB Runtime\v92\runtime\win64
配置
MATLAB_JAVA
D:\install\java\jdk1.8.0_181\jre
2. 配置java环境
JAVA_HOME
D:\install\java\jdk1.8.0_181
CLASSPATH
%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
PATH
;%JAVA_HOME%\jre\bin;%JAVA_HOME%\bin
参考链接: