How do I overcome the Java MCR proxy library initialisation error in Ubuntu?

3 views (last 30 days)
I would like to run a jar, which was built with Matlab's Java Builder on Windows 7 in Ubuntu 14.04 using the MCR libraries. However, I am receiving the following error when testing the MCR installation for an App built with Java Builder:
sudo java -classpath "/opt/MCR/v84/toolbox/javabuilder/jar/javabuilder.jar:/media/sf_shared/for_testing/makesqr.jar" makesqr.Class1 5
java.lang.ExceptionInInitializerError
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration.getProxyLibraryDir(MCRConfiguration.java:260)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$MCRRoot.get(MCRConfiguration.java:71)
58)
...
at makesqr.Class1.main(Class1.java:112)
Caused by: java.lang.NullPointerException
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ProxyLibraryDir.get(MCRConfiguration.java:225)
at com.mathworks.toolbox.javabuilder.internal.MCRConfiguration$ProxyLibraryDir.<clinit>(MCRConfiguration.java:255)
... 10 more
In order to reproduce the error, or to discover where I went wrong, here are all the steps I have done:
Background: I have created an Ubuntu VirtualBox from LAPP stack and added the Ubuntu desktop (Unity: sudo apt-get install ubuntu-desktop). Now I am attempting to install the MCR.
  • Download MCR zip and extract to MCR_SOURCE
  • Go to my folder that contains the files: cd /media/sf_shared/MCR_ SOURCE
  • Change installer_input.txt file:
destinationFolder=/opt/MCR
agreeToLicense=yes
outputFile=/opt/install.log
mode=silent
product.MATLAB
product.MATLAB_Builder_JA
# Note: To find out the required toolboxes >> start Matlab >> run your code and find out which toolboxes were used with: license('inuse')
  • Install MCR: sudo ./install -inputFile /media/sf_shared/MCR_SOURCE/installer_input.txt >> success
  • Note changing the /etc/environment file removes the sidebar from my Ubuntu desktop (another issue), so instead I am exporting the variables directly to a terminal. (Note: X11/app-defaults folder does not exist)
export LD_LIBRARY_PATH="/opt/MCR/v84/runtime/glnxa64:/opt/MCR/v84/bin/glnxa64:/opt/MCR/v84/sys/os/glnxa64:${LD_LIBRARY_PATH}"
export XAPPLRESDIR="/opt/MCR/v84/X11/app-defaults"
  • Change the ownership of the /opt/MCR folder to my user name: sudo chown -R my-user-name:root /opt/MCR/
  • Relax file and folder permissions for the /opt/MCR/ folder: sudo find /opt/MCR -type f -exec chmod 775 {} \; and sudo find /opt/MCR -type d -exec chmod 775 {} \;
  • Install Java on Ubuntu: sudo apt-get install openjdk-7-jre; check existence with java-version (see here for details).
  • Create the Java package makesqr as explained in "Matlab's JavaBuilder tutorial". This step is done on my Windows 7 machine, which runs Matlab R2014b (asserted that this is in accordance with the downloaded MCR earlier on). Matlab ver states that Java Version: Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot™ 64-Bit Server VM mixed mode is used, and MATLAB Builder JA (Version 2.3.2).
  • Test that it runs in Windows:
C:\>java -classpath "C:\MATLAB\R2014b\toolbox\javabuilder\jar\javabuilder.jar";C:\MATLAB\R2014b\work\makesqr\for_testing\makesqr.jar makesqr.Class1 5
ans =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
  • Make the package available to Ubuntu: I have copied the for_testing directory to a folder that my Ubuntu VM and Windows machine share. (double check ownership and permissions - similar to MCR folder step)
  • Test MCR with Java:
sudo java -classpath "/opt/MCR/v84/toolbox/javabuilder/jar/javabuilder.jar:/media/sf_shared/for_testing/makesqr.jar" makesqr.Class1 5
This is where the above mentioned error message occurs. The error message indicates that the MCRConfiguration$ProxyLibraryDir cannot be obtained.
  • What is this MCR configuration library directory?
  • Do I need to add "this folder" to the classpath?
  • Is something wrong of how the LD_LIBRARY_PATH or XAPPLRESDIR were set?

Accepted Answer

Wolfgang Garn
Wolfgang Garn on 22 Jun 2015
Thanks to Martijn's (Mathworks) prompt response. We have now two solutions that work:
  1. _"Please try running your application as normal user without sudo."
  2. "Or alternatively use "sudo -i" to get an interactive su session, in there use "export LD_LIBRARY_PATH=…." and then try running the application from here."
The first one meant for me simply:
java -classpath "/opt/MCR/v84/toolbox/javabuilder/jar/javabuilder.jar:/media/sf_shared/for_testing/makesqr.jar" makesqr.Class1 5
The second solution:
sudo -i
export LD_LIBRARY_PATH="/opt/MCR/v84/runtime/glnxa64:/opt/MCR/v84/bin/glnxa64:/opt/MCR/v84/sys/os/glnxa64:${LD_LIBRARY_PATH}"
export XAPPLRESDIR="/opt/MCR/v84/X11/app-defaults"
java -classpath "/opt/MCR/v84/toolbox/javabuilder/jar/javabuilder.jar:/media/sf_shared/for_testing/makesqr.jar" makesqr.Class1 5
Both of them worked for me!
  1 Comment
David Clifford
David Clifford on 15 Sep 2015
Hi, I was wondering how you might apply this solution to a Webapp (tomcat7) that uses Matlab created jar files? I get the exact same error on my Catalina.out. Can I start tomcat with the same parameters you used above (root, classpath,etc)?
Thanks in advance

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!