[ACCEPTED]-How to install a specific JDK on Mac OS X?-installation
In a comment under @Thilo's answer, @mobibob 8 asked how to set JAVA_HOME in your .bash_profile 7 on a Mac. Answer:
This will dynamically assign 6 to JAVA_HOME the location of the first JDK 5 listed in the "General" tab of 4 "Java Preferences" utility.
See 3 Apple Technical Q&A 1170: https://developer.apple.com/library/content/qa/qa1170/_index.html
If you 2 prefer parentheses to backticks for command 1 substitution, this also works:
As the message says, you have to go to Apple, not 9 Sun, for Java on the Mac. As far as I know, Apple 8 JDK 6 is installed by default on Mac OS 7 X 10.6 (Snow Leopard). Maybe you need to 6 install the developer tools from your Mac 5 OS X installation DVD (the dev tools are 4 an optional install from the OS DVD).
NOTE This 3 answer from 16 Oct 2009 is now outdated; you 2 can get the JDK for Mac OS X from the regular 1 JDK download page on Oracle's website now.
For people using any LION OS X 10.7.X
They 2 uploaded Java SE 6 version 1.6.0_26 available 1 here
I bought a MacBook Pro yesterday (Mac OS X v10.8 (Mountain 9 Lion)) and there is no JDK installed by 8 default...
As well as javac, I also found 7 it didn't have packages such as SVN installed. It 6 turns out you can get everything from the 5 Apple developer page (you will need to register with your AppleID). SVN 4 is part of the "Command Line Tools" package.
This 3 is what happens on a fresh MacBook:
Hopefully 2 this will help out other newbies like me 1 ;)
The explanation is that JDK is a bit specific and does not contain the library tools.jar. For my development, I need this library 5 and Mac's JDK doesn't provide it:
tools.jar 4 does not exist. Classes usually located 3 here are instead included in classes.jar. Scripts 2 that rely on the existence of tools.jar 1 need to be rewritten accordingly.
The easiest way is to use Homebrew. Install Homebrew 2 and then:
brew tap caskroom/versions brew cask install java7
You can list all available versions 1 using the following command:
brew cask search java
Mac comes with the JDK, for more information 1 check:
As of Mac OS X v10.6 (Snow Leopard), you can 4 run Java 6 in 32-bit mode on either 32-bit 3 or 64-bit Intel processor equipped Macs.
If you 2 cannot upgrade to Snow Leopard, Soy Latte is a pre-compiled 1 version of Java 6 for Intel 32-bit.
Compiling with -source 1.5 -target 1.5 (in 12 a JDK 6 environment) will honor only language 11 elements that were in 1.5 and prior. Great. But 10 there were no language changes in 6 anyway. Problem 9 with this approach (on Mac with 1.6) is 8 that using classes that came AFTER 1.5 will 7 still compile because they exist in the 6 rt.jar. So one could run in a 1.5 env and 5 get a class not found exception with no 4 prior warning when compiling. I found this 3 out the hard way with javax.swing.event.RowSorterEvent/Listener. Both 2 entered "Since 1.6" but are not caught with 1 -source 1.5
There are various tricky issues with having 5 multiple versions of Java (Apple's own Java 4 6 and Oracle JDK 7 or even 8) on one's Mac 3 OS X system, and using different versions 2 for different applications. I spent some 1 time writing up my experience of my experience of installing and configuring various versions of JDK on Mac OS X 10.9.2.
If you installed brew, cmd below will be 1 helpful:
brew cask install java
Check this awesome tool sdkman to manage your 2 jdk and other jdk related tools with great 1 ease!
$sdk list java $sdk install java <VERSION>
Since most answers are out of date, here's 12 what works as of end of 2018 under the assumption 11 that
- You want to install the GPL version of OpenJDK.
- You do not want to install Homebrew
In that case, grab the desired version 10 from one the many available, freely usable 9 OpenJDK editions, e.g.:
- Amazon Corretto (Great for production, includes backports)
- Oracle GPLv2 OpenJDK
Some of these include 8 installers, but if not you can do the following. Assuming 7 here version 11.0.1 for Mac. In your favorite 6 shell, run:
tar -xzf openjdk-11.0.1_osx-x64_bin.tar.gz sudo mv jdk-11.0.1.jdk /Library/Java/JavaVirtualMachines # Fix owner and group sudo chown -R root:wheel /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk # (Optional) Check if the new JDK can be found /usr/libexec/java_home => /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home
 Note that the Oracle branded 5 JDK has significant licensing restrictions allowing you its use basically 4 only for testing, i.e., not for production. If you do not have a support agreement 3 with Oracle, then it seems risky to me to 2 use their JDK, especially since the differences to OpenJDK are minimal.
Edit: added 1 more choices
In the year 2021 you can use just
brew install openjdk@11
and you will find your JDK here:
I think this other Stack Overflow question 8 could help:
How to get JDK 1.5 on Mac OS X
It basically says that if you 7 need to compile or execute a Java application 6 with an older version of the JDK (for example 5 1.4 or 1.5), you can do it using the 1.6 4 because it is backwards compatible. To do 3 it so you will need to add the parameter 2
-source 1.5 and/or
-target 1.5 in the javac options or in your 1 IDE.
JDK is the Java Development Kit (used to 10 develop Java software).
JRE is the Java Runtime 9 Environment (used to run any .jar file 'Java 8 software').
The JDK contains a JRE inside 7 it.
On Windows when you update Java, it updates 6 the JRE automatically.
On Mac you do not 5 have a JRE separated you have it, but inside 4 the JDK, so when you update Java it will 3 update your JRE which is inside your JDK; it 2 doesn't install an JDK for you. You need 1 to get it from somewhere else.
As a rule you cannot install other versions 9 of Java on a Mac than those provided by 8 Apple through Software Update. If you need 7 Java 6 you must have a 64-bit Intel computer. You 6 should always have Java 5 and 1.4 and perhaps 5 1.3 installed if you have at least OS X 4 10.4.
If you have VERY much elbow grease 3 and is willing to work with beta software 2 you can install the OpenJDK under OS X, but 1 I don't think you want to go there.
More Related questions