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.
- 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.