Change the MATLAB 2016 JVM

Tags: #<Tag:0x00007fb883f64530> #<Tag:0x00007fb883f8fbe0> #<Tag:0x00007fb883f8eb78> #<Tag:0x00007fb883f8dc00> #<Tag:0x00007fb883f8cdf0>


This is not actually a ImageJ problem.
I’m using MATLAB 2016b and need to call the TrackMate from there via script.

Since to run TrackMate from Matlab I have to do both of them running above the same JVM and the TrackMate only runs in Java 8, a installed the JRE for Java 8 and set the variable MATLAB_JAVA to points to JRE directory.

The problem is when I set the previous mentioned variable and open the MATLAB, I receive in the prompt command a message informing that the all the configuration made are no being saved and the config file is corrupted. Checking on MATLABs forum [1] I confirm that this situation is related to the Java 8.

  • MATLAB 2016b ships Java 7;

So, I’m stuck on this.

Anybody knows any workaround?



Dear @Helder,
I faced a similar problem some time ago with Matlab 2015b.
I used this script (1.4 KB)

that I found somewhere (I don’t remember where :pensive:) in the web, it creates a shortcut on the desktop that will use the java vm you want.

For me it worked well,
have a nice day
Emanuele Martini


Hi @emartini, thank you very much for your help.
I’ll test and will let you (and the others) know if it worked for me.

Thank you again!


I had the exact same problem but in my case the script shared by @emartini, found on the Mathworks website, did not solve the issue.


I am sorry,
I think it could be the Matlab Version I used it on Matlab 2015b or the OS I am using an OSX 10.9.5

let’s hope to find something helpful,
have a nice day

thank @tinevez I found the matlabcentral page


@tinevez, yes… I didnt work for me either…

Somebody told me that it works on MATLAB 2017a… I’ll try it and let you all know.

thank you.


I just tried on Windows, and I get the following message when starting Matlab (2016a) with MATLAB_JAVA pointing to a 1.8.0 JRE:

The desktop configuration was not saved successfully

But this doen’t prevent me from starting the ImageJ.m script from within Matlab.

@Helder did you get any further error messages?
Also, did you try the workaround mentioned in your linked post:

  1. switch to a 1.7 JRE,
  2. save the layout,
  3. switch to Java 8, and
  4. select the saved layout?

As far as I understand, this should not be a blocking issue.


Hi @imagejan, yes, that is the exactly message I’ve got. Of course, it doesnt prevent me either to start Fiji (Miji command).

And Yes, I have tried the workaround the you mentioned. But, If I do this, I’ve got another message telling me about the corruption of those configuration files. Even the ‘command history’ can not be retrieved!

I’ll try to use the MATLAB 2017a and see if I can start Miji and run the trackmate from there, after redirect matlab for Java 8 of course.

Thank you.


Hi guys!

I’ve installed the MATLAB 2017a. After set the variable MATLAB_JAVA to point to a Java 8 JRE the Fiji/Trackmate worked fine, as expected…

So, seems that is no way to solve the problem in MATLAB 2016 but, the 2017 version works like a charm :wink:

Thank you all!


Thanks for testing and following up! That is great news! :smile:


@ctrueden its my pleasure.
I hope to contribute developing ImageJ in the future…