开发者

MATLAB JA Builder throws NullPointerException in MCRConfiguration

I'm trying to execute 开发者_StackOverflow中文版a MATLAB function from Java using JA Builder.

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

Line 36 in getmagic.java is:

n = new MWNumericArray(Double.valueOf(args[0]), MWClassID.DOUBLE);

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.

Any thoughts? Thanks


You need to configure the following environment variables:

LD_LIBRARY_PATH

XAPPLRESDIR

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


This setting worked for me on Linux:

export LD_LIBRARY_PATH=/usr/lib/matlab-8.6/runtime/glnxa64 \
       /usr/lib/matlab-8.6/bin/glnxa64 \
       /usr/lib/matlab-8.6/sys/os/glnxa64 \
       /usr/lib/matlab-8.6/sys/opengl/lib/glnxa64

You can find instructions for other OSes at http://www.mathworks.com/help/compiler_sdk/java/mcr-path-settings-for-run-time-deployment.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜