I need to install MATLAB using an internet connection, but according to the docs I can't install MATLAB with a connection if I have JDK 7 installed on Mountain Lion. According to MATLAB, the solution is:

1) Install/activate manually without using Internet. MATLAB will work fine even if you have JDK 7 installed because it will still be using Apple's Java 6 that does not get removed when JDK 7 is installed.

2) Alternatively, you may uninstall JDK 7 which will let you install and activate MATLAB using Internet.

I need an internet connection, so number 1 won't work. I need JDK 7 as well, so I was wondering if I would be able to uninstall JDK 7, then install MATLAB, then reinstall JDK 7 without breaking MATLAB. Is this possible, or are there any other workarounds?

  • Apple's JDK 6 does not get removed when JDK 7 is installed
    – mmmmmm
    Commented Oct 8, 2013 at 11:49
  • @Mark I'm just relaying what the MathWorks page says. According to their page that I linked to, there is no way to install MATLAB with an internet connection on Mountain Lion with JDK 7 installed.
    – fvrghl
    Commented Oct 8, 2013 at 12:04
  • I realise that which makes me think that MathWorks answer is not fully correct, the Apple JDK is on the disk but not from /usr/bin/java
    – mmmmmm
    Commented Oct 8, 2013 at 12:05
  • @Mark I've tried installing with JDK7, 10.8x, and an internet connection and I get an error. My question is about whether or not it's possible to install JDK7 on 10.8x if MATLAB is installed and not have the JDK break MATLAB.
    – fvrghl
    Commented Oct 8, 2013 at 12:09
  • You could download everything and then turn off all network connections to try to install without internet. (But I do not believe MathWork's comment for that install)
    – mmmmmm
    Commented Oct 8, 2013 at 12:12

1 Answer 1


Short answer: Yes. It'll work fine if you put JDK 7 back after the installation. Though you might have to do the same thing if you decide to de-activate Matlab at some point.

You've got a few options.

Option A: Use a newer Matlab

An easy fix could be to use Matlab R2014a. It supports Mavericks and comes with its own bundled JVM so it doesn't use the system JVMs. I just installed it on my Mavericks machine last week, which didn't even have Apple's Java 1.6 installed, and it worked fine. (I also looked at the source to confirm its "Activate" uses the bundled JRE.)

Option B: Temporarily Uninstall JDK 7

If that's not an option, it sounds like removing the JDK 7 is only needed during the installation process. I'd guess because it shells out to the default java for the software activation program instead of using the Matlab app's normal JRE detection and embedding logic. "Activate MATLAB" is a separate Java program, not part of the Matlab executable, so it's run using java. So you can put JDK 7 back once Matlab is installed; normal Matlab execution won't use it.

You can conveniently temporarily uninstall the JDK 7 by just moving it out of the /Library/Java directory so the system doesn't see it. Then you don't have to go through the whole download and installation process again.

cd /Library/Java/JavaVirtualMachines
mkdir ~/disabledJVMs
sudo mv jdk1.7.0_51.jdk ~/disabledJVMs
% also change the JAVA_HOME definition if you set it in an rc file or /etc/launchd.conf

% ... now install Matlab ...

% And restore the JDK
sudo mv ~/disabledJVMs/jdk1.7.0_51.jdk .

You can confirm the uninstallation worked with /usr/libexec/java_home.

Option C: Hack the Matlab Installer!

If you want to get fancy, you could actually hack the Matlab installer to force it to use Apple's JDK 1.6 for activation.

During the installation process, once all the files are copied in to /Applications but before you launch the Activation dialog, do this:

  • Go in to /Applications in Finder, right-click MATLAB, and choose "Show Package Contents".
  • Start an admin-enabled text editor from the Terminal with sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit.
  • Open bin/activate_matlab.sh in that TextEdit. Find where it's setting the paths to java and hardcode them to point to the Apple 1.6 JDK, which is in /System/Library/Java/JavaVirtualMachines/1.6.0.jdk. In the R2014a activate_matlab.sh, it's in functions setVMenvironment and setVMpath, and it sets up a JRE_HOME variable, which needs to be set to /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home.
  • Do the same to deactivate_matlab.sh

And then you can proceed to the software activation step in the Matlab installer you left running, and I bet it will work even with JDK 7 in place.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .