0

I am new to mac (coming from the windows world). 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.
1

The only one that matters if running via /usr/bin/java is the value of JAVA_HOME and can be set for all terminals etc e.g. to get latest 1.7 add to your startup shell script (e.g. ~/.bashrc)

export JAVA_HOME=`/usr/libexec/java_home -v '1.7*'

Unfortunately apps (ie GUI installed as OS X Application bundles e.g. Eclipse) access the java that is set up in their package information (Which can be a fullpath to one in /Library or /System/Library or could be /usr/bin/java) so they need to be looked at at a case by case basis.

The difference between installing a JDK in /Library/Java/JavaVirtualMachines vs /System/Library/Java/JavaVirtualMachines/ is that the latter is installed by Apple as part of the OS and the other is by a third party

The CurrentJDK is the way Apple versions OS X frameworks - in Java's case I don't think it matters now (in pre 1.7 days it might have been how the old Java preference tab worked but that is a guess)

You must log in to answer this question.

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