Hot questions for Using Ubuntu in matlab

Question:

I recently installed Matlab 2014b on a Packard Bell LJ65 laptop with Ubuntu 14.04, and every time I open it the following error pops up on the command:

javax.media.opengl.GLException: X11GLXDrawableFactory - Could not initialize shared resources for :0
        at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:316)
        at jogamp.opengl.SharedResourceRunner.run(SharedResourceRunner.java:295)
        at java.lang.Thread.run(Unknown Source)
    Caused by: javax.media.opengl.GLException: Startup Class Loader-SharedResourceRunner: Error making temp context(1) current: display 0x7f53a421e050, context 0x7f53a4247610, drawable X11OnscreenGLXDrawable[Realized true,
        Factory   jogamp.opengl.x11.glx.X11GLXDrawableFactory@4c932b8e,
        Handle    0x6800002,
        Surface   WrappedSurface[ displayHandle 0x7f53a421e050
    , surfaceHandle 0x6800002
    , size 64x64
    , UOB[ OWNS_SURFACE | WINDOW_INVISIBLE ]
    , X11GLXGraphicsConfiguration[X11GraphicsScreen[X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x7f53a421e050, owner true, ResourceToolkitLock[obj 0x52109ee8, isOwner true, <4130bb6f, 666195d8>[count 2, qsz 0, owner <Startup Class Loader-SharedResourceRunner>]]], idx 0], visualID 0x221, fbConfigID 0xbb,
        requested GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono  , hw, GLProfile[GL2/GL2.sw], on-scr[.]],
        chosen    GLCaps[glx vid 0x221, fbc 0xbb: rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 24/0/0, dbl, mono  , hw, GLProfile[GL2/GL2.sw], on-scr[.]]]
    , surfaceLock <10b4cc6b, 4dd88d5e>[count 1, qsz 0, owner <Startup Class Loader-SharedResourceRunner>]
    , X11DummyUpstreamSurfaceHook[ 64x64]
    , upstreamSurface false ]]
        at jogamp.opengl.x11.glx.X11GLXContext.createImpl(X11GLXContext.java:346)
        at jogamp.opengl.GLContextImpl.makeCurrentWithinLock(GLContextImpl.java:662)
        at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:561)
        at jogamp.opengl.GLContextImpl.makeCurrent(GLContextImpl.java:518)
        at jogamp.opengl.x11.glx.X11GLXDrawableFactory$SharedResourceImplementation.createSharedResource(X11GLXDrawableFactory.java:292)
        ... 2 more

I thought I could ignore it, since the program runs as normal for most of the tasks. But, when trying to plot, the following error appears:

Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Profile GL_DEFAULT is not available on X11GraphicsDevice[type .x11, connection :0, unitID 0, handle 0x0, owner false, ResourceToolkitLock[obj 0x6860dc76, isOwner false, <2f29fc83, 6d8114a5>[count 0, qsz 0, owner <NULL>]]], but: []
    at javax.media.opengl.GLProfile.get(GLProfile.java:901)
    at javax.media.opengl.GLProfile.getDefault(GLProfile.java:632)
    at javax.media.opengl.GLCapabilities.<init>(GLCapabilities.java:84)
    at com.mathworks.hg.peer.JavaSceneServerPeer.getCaps(JavaSceneServerPeer.java:147)
    at com.mathworks.hg.peer.JavaSceneServerPeer.doCreateCanvas(JavaSceneServerPeer.java:676)
    at com.mathworks.hg.peer.JavaSceneServerPeer.access$200(JavaSceneServerPeer.java:50)
    at com.mathworks.hg.peer.JavaSceneServerPeer$2.run(JavaSceneServerPeer.java:650)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

and no plot is produced.

I searched and found many problems with javax but not this one exactly. Any suggestions?

EDIT: There is also an error appearing when loading matlab from the terminal

libGL error: unable to load driver: nouveau_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: nouveau
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast

Answer:

I managed to solve it on my own following what was suggested in http://www.mathworks.com/matlabcentral/answers/170276-matlab2014b-generates-libgl-error-unable-to-load-driver-nouveau_dri-so-at-startup

basically, first download this set of drivers:

wget ftp://ftp.pbone.net/mirror/elrepo.org/extras/el6/x86_64/RPMS/mesa-dri-drivers-8.0.5-1.el6.elrepo.x86_64.rpm

Then unpack it with:

rpm2cpio mesa-dri-drivers-8.0.5-1.el6.elrepo.x86_64.rpm | cpio -idmv

(if rpm2cpio is not installed then sudo get-apt rpm2cpio)

and copy the file in WhereEverYouUnpacked/usr/lib64/dri/nouveau_dri.so to /usr/lib/dri/

Note that the copying into /usr/ has to be done as root

Question:

While attempting to start Matlab R2013b in Ubuntu, I get the following dialog box with an error message and Matlab crashes and closes. Can someone explain the error and how to rectify it?


Answer:

This is a known JDK bug. It is addressed in this question pretty thoroughly from the java perspective.

When it comes to Matlab, you options seem to be (apart from upgrading Matlab and/or OS):

  1. Add the following JVM startup option through java.opts file:

    -Djava.util.Arrays.useLegacyMergeSort=true

  2. Use a different java version by setting MATLAB_JAVA environmental variable. It may result in all sorts of side-effects, depending on which Matlab / Java combination you end up using.

Question:

I want to open Matlab without cd /usr/local/MATLAB/R2015b/bin and the sudo ./matlab.

So I sudo gedit ~/.bashrc and write the following commands in the ending:

export MATLAB_ROOT="/usr/local/MATLAB/R2015b/bin"

if [ -d "${MATLAB_ROOT}" ]; then
   export PATH="${PATH}:${MATLAB_ROOT}"
fi

After source ~/.bashrc and I use echo $PATH to see that the path of matlab does exist. But when I use matlab to open the it, it will be stuck at Picked up JAVA_TOOL_OPTIONS: whereas cd /usr/local/MATLAB/R2015b/bin and the sudo ./matlab commands work well.

And if I directly use sudo ./matlab, it will show sudoļ¼š./matlab: command not found

Other information: which java shows /usr/bin/java

unset JAVA_TOOL_OPTIONS will cause another error.


Answer:

Oh, I found the problem, I use the command JAVA_TOOL_OPTIONS=/usr/local/MATLAB/R2015b/bin or unset JAVA_TOOL_OPTIONS, and then get the error as follows.

It makes me recall the sudo command, so it might be a problem of permission right. Since I have to open Matlab without leaving that directory, I use ln -s /usr/local/MATLAB/R2015b/bin/matlab /path/to/your/current and then sudo ./matlab. It works.

But how to really solve this problem remains unknown. The other methods I saw like sudo apt-get remove jayatana and sudo rm /usr/share/upstart/sessions/jayatana.conf may cause unpredictable result, so I could not try them.