MATLAB JA Builder在MCRConfiguration中引发NullPointerException [英] MATLAB JA Builder throws NullPointerException in MCRConfiguration
问题描述
我正在尝试使用JA Builder从Java执行MATLAB函数.
I'm trying to execute a MATLAB function from Java using JA Builder.
我遵循了MATLAB JA Builder帮助文档-HelloWorld和MagicSquare示例,每次都收到以下堆栈跟踪:
I followed the MATLAB JA Builder help documentation - the HelloWorld and MagicSquare examples and receive the following stack trace each time:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration.getProxyLibraryDir(MCRConfiguration.java:163)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$MCRRoot.get(MCRConfiguration.java:77)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$MCRRoot.<clinit>(MCRConfiguration.java:87)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration.getMCRRoot(MCRConfiguration.java:92)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ModuleDir.<clinit>(MCRConfiguration.java:66)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration.getModuleDir(MCRConfiguration.java:71)
at com.mathworks.toolbox.javabuilder.internal.MWMCR.<clinit>(MWMCR.java:1573)
at com.mathworks.toolbox.javabuilder.MWUtil.GetUnknownClassID(MWUtil.java:727)
at com.mathworks.toolbox.javabuilder.MWClassID.<clinit>(MWClassID.java:41)
at getmagic.main(getmagic.java:36)
Caused by: java.lang.NullPointerException
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ProxyLibraryDir.get(MCRConfiguration.java:143)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ProxyLibraryDir.<clinit>(MCRConfiguration.java:158)
... 10 more
getmagic.java中的第36行是:
Line 36 in getmagic.java is:
n = new MWNumericArray(Double.valueOf(args[0]), MWClassID.DOUBLE);
是否需要包含另一个JAR或一组配置文件?该程序当前引用了MATLAB JA Builder帮助文档中指定的来自MATLAB的javabuilder.jar和已编译的magicsquare.jar.
Is there another JAR or set of config files I need to include? The program currently references javabuilder.jar and the compiled magicsquare.jar from MATLAB as specified in the MATLAB JA Builder help documentation.
有什么想法吗?谢谢
推荐答案
您需要配置以下环境变量:
You need to configure the following environment variables:
LD_LIBRARY_PATH
XAPPLRESDIR
在安装MCR时,安装程序会告诉您所需的值(取决于您的mcrroot,即安装MCR的目录).例如对于/usr/local/MATLAB/
设置
When installing MCR, the installer would tell you their required values (which depend on your mcrroot, the dir where MCR is installed). e.g. for /usr/local/MATLAB/
set
export XAPPLRESDIR=/usr/local/MATLAB/MATLAB_Compiler_Runtime/v81/X11/app-defaults
这篇关于MATLAB JA Builder在MCRConfiguration中引发NullPointerException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!