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:
01 | Warning: Caught Exception while retrieving executable temp base directory: |
02 | java.lang.RuntimeException: Could not determine a temporary executable directory |
03 | at com.jogamp.common.util.IOUtil.getTempDir(IOUtil.java:1391) |
04 | at com.jogamp.common.util.cache.TempFileCache.<clinit>(TempFileCache.java:80) |
05 | at com.jogamp.common.util.cache.TempJarCache.initSingleton(TempJarCache.java:89) |
06 | at com.jogamp.common.os.Platform$1.run(Platform.java:201) |
07 | at java.security.AccessController.doPrivileged(Native Method) |
08 | at com.jogamp.common.os.Platform.<clinit>(Platform.java:179) |
09 | at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:120) |
10 | at com.mathworks.hg.peer.JavaSceneServerPeer.initializeJOGL(JavaSceneServerPeer.java:134) |
11 | at com.mathworks.hg.peer.JavaSceneServerPeer.<clinit>(JavaSceneServerPeer.java:104) |
12 | at java.lang.Class.forName0(Native Method) |
13 | at java.lang.Class.forName(Unknown Source) |
14 | at com.mathworks.mde.desk.StartupClassLoader.loadClass(StartupClassLoader.java:258) |
15 | at com.mathworks.mde.desk.StartupClassLoader.access$900(StartupClassLoader.java:25) |
16 | at com.mathworks.mde.desk.StartupClassLoader$2.run(StartupClassLoader.java:244) |
17 | at java.lang.Thread.run(Unknown Source) |
18 | Exception in thread "Startup Class Loader" java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\michael\Documents\MATLAB\gluegen-rt.dll |
19 | at java.lang.ClassLoader.loadLibrary(Unknown Source) |
20 | at java.lang.Runtime.load0(Unknown Source) |
21 | at java.lang.System.load(Unknown Source) |
22 | at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:596) |
23 | at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64) |
24 | at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:96) |
25 | at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:459) |
26 | at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:388) |
27 | at com.jogamp.common.os.Platform$1.run(Platform.java:209) |
28 | at java.security.AccessController.doPrivileged(Native Method) |
29 | at com.jogamp.common.os.Platform.<clinit>(Platform.java:179) |
30 | at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:120) |
31 | at com.mathworks.hg.peer.JavaSceneServerPeer.initializeJOGL(JavaSceneServerPeer.java:134) |
32 | at com.mathworks.hg.peer.JavaSceneServerPeer.<clinit>(JavaSceneServerPeer.java:104) |
33 | at java.lang.Class.forName0(Native Method) |
34 | at java.lang.Class.forName(Unknown Source) |
35 | at com.mathworks.mde.desk.StartupClassLoader.loadClass(StartupClassLoader.java:258) |
36 | at com.mathworks.mde.desk.StartupClassLoader.access$900(StartupClassLoader.java:25) |
37 | at com.mathworks.mde.desk.StartupClassLoader$2.run(StartupClassLoader.java:244) |
38 | at java.lang.Thread.run(Unknown Source)</clinit></clinit></clinit></clinit></clinit></clinit></clinit> |
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!