Using Fedora’s OpenJDK with MATLAB

Since MATLAB requires Java for some of its features (e.g. for displaying the GUI or running Java programs within MATLAB), it ships with Sun’s Java Runtime Environment (JRE). Most people already have installed a JRE on their system that usually is newer than the one MATLAB comes with. Therefore, it seems to be a good idea to let MATLAB make use of the installed JRE instead of its own. This easily can be done by setting the environment variable MATLAB_JAVA. That’s the theory.

In practice, changing MATLAB’s JRE makes some trouble—at least when you are running Linux. Currently, I’m running MATLAB R2008b (aka 7.7) on Fedora 10 and notice some problems with MATLAB’s own JRE: First, printing does not work. Second, when starting MATLAB I get some strange error (locking assertion failure), which luckily does not seem to have any further consequences. Therefore, I decided to switch to OpenJDK, which comes with Fedora. Setting MATLAB_JAVA to /usr/lib/jvm/jre should do the job. Unfortunately, with this setting MATLAB fails to start, giving me the following error message:

Unable to initialize com.mathworks.mwswing.MJStartup
Fatal Error on startup: Failure loading desktop class

Although I spent some time in debugging this issue, I still have no clue what’s going wrong. My hope is that this issue will be resolved in the next release of MATLAB.

And indeed, MATLAB R2009a (aka 7.8) can be started using OpenJDK. However, MATLAB’s help browser displays only empty pages, which actually are not very helpful. When opening the help browser I get the following Java error:

Exception in thread "Loader for _view_0" java.lang.VerifyError: class org.mozilla.javascript.IdScriptable overrides final method getAttributes.(Ljava/lang/String;Lorg/mozilla/javascript/Scriptable;)I
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at ice.util.Defs.getClass(OEAB)
at ice.util.Defs.newClassInstance(OEAB)
at ice.storm.DefaultFactory.createScripter(
at ice.storm.StormBase.getScripter(
at ice.pilots.html4.ThePilot.doScriptEval(
at ice.pilots.html4.DOMBuilder.loadIfGivenExternalScript(
at ice.pilots.html4.DOMBuilder.endElement(
at ice.dombase.LexBase.endElement(OEAB)
at ice.dombase.LexBase.char_buf(OEAB)
at ice.dombase.LexBase.arraycopy(OEAB)
at ice.dombase.LexBase.parse(OEAB)
at ice.dombase.LexBase.parse(OEAB)
at ice.pilots.html4.ThePilot.do_parse(
at ice.pilots.html4.ThePilot.parse(
at ice.storm.StormBase.do_render_content(
at ice.storm.Viewport.runAsynchronousLoad(

Fortunately, I found out how to fix this problem. The reason for the error is that the developers of OpenJDK decided to place Rhino (an open implementation of JavaScript) into OpenJDK’s bootclasspath, which essentially overrides the (quite old) version of Rhino used by (and shipped with) MATLAB with an incompatible one. Most likely this is a bug in OpenJDK, similar to a bug already reported for

So, what can be done to get rid of this problem? As a workaround (until the developers of OpenJDK finally fix this problem) I suggest to delete the symlink /usr/lib/jvm/java-1.6.0-openjdk-, which currently points to /usr/share/java/rhino.jar.

Now, OpenJDK works fine with MATLAB and I’m even able to print. Apart from that, the fonts look better.

To summarize: MATLAB R2008b does not work with OpenJDK, but MATLAB R2009a does if you remove rhino.jar from OpenJDK.

UPDATE: The IcedTea/OpenJDK guys managed to move OpenJDK’s version of Rhino to a different namespace (as of IcedTea6 1.8), which should solve the problem described in this post.

This entry was posted in MATLAB. Bookmark the permalink.

5 Responses to Using Fedora’s OpenJDK with MATLAB

  1. dope says:

    Good post, but I lost the flow. What Matlab version do you use at the second part? Removing rhino.jar does’nt help me. 🙁

  2. @dope: Thanks for the comment. A added some clarifying words to the end of the entry.

  3. dope says:

    the simplest solution I found is to install Sun’s java and hook it up with the matlab2008. No more complaints then. And the OS can still use OpenJDK.

  4. Scott says:

    I had the same error in Leopard. Turns out it was because I installed Rhino’s js.jar in my ~/Library/Java/Extensions dir a long time ago, which was conflicting in the way you mentioned. Thanks for being the only googleable source on this!

  5. honk says:

    Thank you Scott for the hint in Snow Leopard. Works fine for me to… Thanks also for the googleble source.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.