Follow this Blog!

Sep 15, 2015

f Comment

Matlab: Fix "Caught unexpected exception of unknown type" in MINUTES!

Amazon Do you use Matlab? I was using R2015b Windows 64-bit version of Matlab. I ran this simple plot:
>> x = 1 : 0.1 : 10;
>> y = x.^2;
>> plot(x,y)
And I got this error in the console:
Caught unexpected exception of unknown type
I saw a blank figure window. How do I fix this error so I can plot in Matlab?

Root Cause

When I started Matlab I saw this Java exception:
Exception in thread "Startup Class Loader" java.lang.UnsatisfiedLinkError
The whole exception thread is like this:
Warning: Caught Exception while retrieving executable temp base directory:
java.lang.RuntimeException: Could not determine a temporary executable directory
        at com.jogamp.common.util.IOUtil.getTempDir(IOUtil.java:1391)
        at com.jogamp.common.util.cache.TempFileCache.(TempFileCache.java:80)
        at com.jogamp.common.util.cache.TempJarCache.initSingleton(TempJarCache.java:89)
        at com.jogamp.common.os.Platform$1.run(Platform.java:201)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.jogamp.common.os.Platform.(Platform.java:179)
        at javax.media.opengl.GLProfile.(GLProfile.java:120)
        at com.mathworks.hg.peer.JavaSceneServerPeer.initializeJOGL(JavaSceneServerPeer.java:134)
        at com.mathworks.hg.peer.JavaSceneServerPeer.(JavaSceneServerPeer.java:104)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.mathworks.mde.desk.StartupClassLoader.loadClass(StartupClassLoader.java:258)
        at com.mathworks.mde.desk.StartupClassLoader.access$900(StartupClassLoader.java:25)
        at com.mathworks.mde.desk.StartupClassLoader$2.run(StartupClassLoader.java:244)
        at java.lang.Thread.run(Unknown Source)
Exception in thread "Startup Class Loader" java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\michael\Documents\MATLAB\gluegen-rt.dll
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.load0(Unknown Source)
        at java.lang.System.load(Unknown Source)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:596)
        at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)
        at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:96)
        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:459)
        at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:388)
        at com.jogamp.common.os.Platform$1.run(Platform.java:209)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.jogamp.common.os.Platform.(Platform.java:179)
        at javax.media.opengl.GLProfile.(GLProfile.java:120)
        at com.mathworks.hg.peer.JavaSceneServerPeer.initializeJOGL(JavaSceneServerPeer.java:134)
        at com.mathworks.hg.peer.JavaSceneServerPeer.(JavaSceneServerPeer.java:104)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.mathworks.mde.desk.StartupClassLoader.loadClass(StartupClassLoader.java:258)
        at com.mathworks.mde.desk.StartupClassLoader.access$900(StartupClassLoader.java:25)
        at com.mathworks.mde.desk.StartupClassLoader$2.run(StartupClassLoader.java:244)
        at java.lang.Thread.run(Unknown Source)
This error is the root cause of this problem. People on Google have suggested "This issue is caused by having installed Matlab integration through maple. A file called .maplerc.sh is placed within Matlab's bin/ folder, and it apparently breaks everything." but it's not the cause for me. Read on to see how I fixed it in minutes.

Solution

The solution is to uninstall Matlab and install the 32-bit version of Matlab instead. This is because your Java is 32-bit, and Matlab needs Java to work. Once you've installed the 32-bit Matlab you should be able to plot.

Likewise, if you are using 64-bit Java runtime environment, you should use 64-bit Matlab.

Questions? Let me know!
Please leave a comment here!
One Minute Information - by Michael Wen
Find Michael on Google or Facebook
ADVERTISING WITH US - Direct your advertising requests to Michael