Setting JAVA correctly on MAC

in macOS edited May 2015

Hello All, I did some reading on how and where JAVA HOME is set on a mac machine. I have some assumptions listed below, would be great if someone could go through and provide some feedback on the same.


  • /Library/Java/JavaVirtualMachines is where i see jdk 1.7 and jdk 1.8 installed. Going forward if i install any more JDK versions i presume they will be installed in this path.

  • I see that /System/Library/Java/JavaVirtualMachines/ has 1.6.0.jdk installed. I am assuming this is Apple's Java 6 which came installed with my mac by default? Also, what's the difference between installing a JDK in /Library/Java/JavaVirtualMachines vs /System/Library/Java/JavaVirtualMachines/.

  • /usr/libexec/java_home -V is a utility that lists all the jvm;s on the machine. I rightly see JVM 1.6 (x86, i386), 1.7 and 1.8. I have added "export JAVA_HOME=/usr/libexec/java_home" in my .bash_profile to set my java_home to JDK 1.8.

  • /System/Library/Frameworks contains a bunch of shortcuts within it. I really dont want to spend time understanding frameworks at this point, but this seems to be some kind of redirection layer to decide which JVM to use. There is a folder called /System/Library/Frameworks/JavaVM.framework/Versions which contain's bunch of shortcuts (1.4, 1.6, 1.6.0 etc) that point to CurrentJDK. CurrentJDK is a shortcut to jdk 1.6 (/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents)

What implication does this have? What happens if JAVA_HOME is pointing to JDK 1.8 and /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK points to jdk 1.6.

Does this mean when we change JAVA_HOME, we must change /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK too?


  • There is another folder called /System/Library/Frameworks/JavaVM.framework/Versions/Current/ which is a shortcut to /System/Library/Frameworks/JavaVM.framework/Versions/A. Now, i read in some post that


    The java executables in >/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java are >not the executables that just run the java compiler etc. They are wrappers that >use /usr/libexec/java_home to find the executables.

I am assuming if programs get the latest java from /System/Library/Frameworks/JavaVM.framework/Versions/Current/ and if /System/Library/Frameworks/JavaVM.framework/Versions/Current/ uses /usr/libexec/java_home to find the executables then it would end up using jdk 1.8 in my case. Is this assumption correct?


  • So, there seem to be 4 variable's here,, where $JAVA_HOME is pointing to, where /usr/libexec/java_home takes you,, where does /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK point to and finally where does /System/Library/Frameworks/JavaVM.framework/Versions/Current point to. Would be great if someone could comment on the correct way to setup JAVA_HOME so that all app's, terminal windows etc use the same JVM version.


cross posted [here]



  • Reply 1 of 1
    mr. memr. me Posts: 3,221member

    Contrary to the answer to the question on, Apple does not provide a default installation of Java with OS X. The has been the cause since Apple gave up responsibility for providing Java for OS X and turned that responsibility over to Oracle. If a user needs Java on a computer on which it has not yet been installed, then OS X will prompt the user to download Java from Oracle.

    Only [B]Java 1.7[/B] and [B]Java 1.8[/B] are available from Oracle. However, some Java apps require earlier versions. If a user needs a version of Java that is older than Java 1.7, then [B]Java 1.6[/B] is available for download from Apple. Oracle does not support or provide [B]Java 1.6[/B] or any earlier version for OS X.

    Whichever version of Java you install, installation is done using a standard OS X .pkg installer distributed in standard .dmg mountable disk image files. The [B]Installer[/B] utility does not provide the option to change the default locations of any installed Java component. If you want to change the locations of your Java installation, then you must move them manually. I strongly recommend that you don't do that.
Sign In or Register to comment.