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?
Asked
Active
Viewed 304 times
0

Gherbi Hicham
- 2,416
- 4
- 26
- 41

user_1_1_1
- 903
- 1
- 12
- 27
-
do you get the same error if you run without a graphical interface? (i.e. `matlab -nodesktop -nosplash`) – Tasos Papastylianou Jul 26 '16 at 21:18
-
or, `matlab -nodisplay` even. – Tasos Papastylianou Jul 26 '16 at 21:21
-
@TasosPapastylianou No error that way! But IDE-based GUI is much more convenient than command-line. – user_1_1_1 Jul 26 '16 at 21:29
-
1Sure, I was just checking if your error is related to the GUI / Xdisplay rather than the JVM itself. Seems that way. What java are you using on your machine? If all else fails, Octave has a lovely gui these days btw :p – Tasos Papastylianou Jul 26 '16 at 21:53
1 Answers
1
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):
Add the following JVM startup option through
java.opts
file:-Djava.util.Arrays.useLegacyMergeSort=true
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.

Community
- 1
- 1

nirvana-msu
- 3,877
- 2
- 19
- 28
-
Does matlab come with its own version of java on linux? Or does it rely on system-wide libraries? – Tasos Papastylianou Jul 26 '16 at 22:25
-
2It comes with its own JVM on all operating systems. It does not respect windows `JAVA_HOME` environmental variable as mentioned in [this answer](http://stackoverflow.com/questions/36970686/change-the-default-jvm-version-in-matlab/36971915#36971915), and pretty sure the same is true for linux. You need to set `MATLAB_JAVA` instead. – nirvana-msu Jul 26 '16 at 22:29
-
@TasosPapastylianou Currently Matlab is using `Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode` and i guess this is the MATLAB's internal JRE and has not got anything to do with my computer's java settings. There's no java on my computer. Does Octave have all basic capabilities of Matlab like all of Matlab's plotting abilities and basic optimization algorithms? Does it handle matrices as well as matlab? I know this merits a separate SO question of its own, but... – user_1_1_1 Jul 26 '16 at 23:37
-
@nirvana-msu Any suggestion which Matlab version corresponds to which java version in general, an online list for example... – user_1_1_1 Jul 26 '16 at 23:39
-
1You can find the list of bundled JVM versions for Matlab releases on the [wiki](https://en.wikipedia.org/wiki/MATLAB#Release_history) page. Using a different major java version would likely result in severe issues. Using a different minor version should be ok. I would strongly advise, though, to try setting `useLegacyMergeSort` flag via `java.opts` first. It is much simpler and should not result in any problems. – nirvana-msu Jul 26 '16 at 23:46
-
-
1Just add this line to `java.opts`. Read the docs on how to start Matlab properly so JVM would pick up this configuration (one option is to have `java.opts` in the same directory you start Matlab in). – nirvana-msu Jul 26 '16 at 23:49
-
1@user_1_1_1 if the above fails, then yes, try Octave, it's not always 100% compatible but I've had very few problems I couldn't work around, and basic functionality is all there. On linux if you want the latest version you'd have to compile from source though, which, if you've not done before, you might stumble there. Also, what ubuntu do you have? If it's an older version, it may be worth trying on a newer ubuntu version? – Tasos Papastylianou Jul 26 '16 at 23:55
-
@TasosPapastylianou Have Ubuntu 16.04. Will give a try to building from source. Hope it works because i do go for open-source whenever it is possible without sacrificing productivity. It is so easy to code stuff in matlab that it's difficult to abandon it. – user_1_1_1 Jul 27 '16 at 00:04
-
1happy to help if you get stuck building from source. just drop me a line. – Tasos Papastylianou Jul 27 '16 at 00:38
-
@TasosPapastylianou Thanks much! I found good guide [here](http://www.schoeps.org/home/2015/06/five-simple-instructions-to-compile-octave-4-on-ubuntu/). But i had a slight glitch, thought best to ask a question [here](http://stackoverflow.com/q/38603331/6557795). See if you can help. – user_1_1_1 Jul 27 '16 at 03:43