Question or issue on macOS:
I want to install a specific JDK (the latest for example). For this, I went to the JDK download homepage: http://java.sun.com/javase/downloads/index.jsp.
I looked for a Mac version, but I'm a bit surprised to only see downloadable versions for Linux, Windows and Solaris…
This site requires JavaScript to be enabled. As far as I know, Apple JDK 6 is installed by default on Mac OS X 10.6 (Snow Leopard). Maybe you need to install the developer tools from your Mac OS X installation DVD (the dev tools are an optional install from the OS DVD).
Here's the message for Mac:
OK BUT… when I update Java with Mac I have a JRE and not a JDK…
I don't understand why a JDK version doesn't exist that is easily downloadable/installable (like a jar to unzip?) for Mac…
How to solve this problem?
Solution no. 1:
In a comment under @Thilo's answer, @mobibob asked how to set JAVA_HOME in your .bash_profile on a Mac. Answer:
This will dynamically assign to JAVA_HOME the location of the first JDK listed in the 'General' tab of 'Java Preferences' utility.
See Apple Technical Q&A 1170: https://developer.apple.com/library/content/qa/qa1170/_index.html
EDIT:
If you prefer parentheses to backticks for command substitution, this also works:
Solution no. 2:
As the message says, you have to go to Apple, not Sun, for Java on the Mac. As far as I know, Apple JDK 6 is installed by default on Mac OS X 10.6 (Snow Leopard). Maybe you need to install the developer tools from your Mac OS X installation DVD (the dev tools are an optional install from the OS DVD).
Do I Need To Download Java For Mac Os X 10.6
See: http://developer.apple.com/java/
NOTE This answer from 16 Oct 2009 is now outdated; you can get the JDK for Mac OS X from the regular JDK download page on Oracle's website now.
Solution no. 3:
For people using any LION OS X 10.7.X
They uploaded Java SE 6 version 1.6.0_26 available here
Solution no. 4:
I bought a MacBook Pro yesterday (Mac OS X v10.8 (Mountain Lion)) and there is no JDK installed by default…
As well as javac, I also found it didn't have packages such as SVN installed. It turns out you can get everything from the Apple developer page (you will need to register with your AppleID). SVN is part of the 'Command Line Tools' package.
This is what happens on a fresh MacBook:
Hopefully this will help out other newbies like me 😉
Solution no. 5:
Mac comes with the JDK, for more information check:
Solution no. 6:
The explanation is that JDK is a bit specific and does not contain the library tools.jar. For my development, I need this library and Mac's JDK doesn't provide it:
(Cf. http://developer.apple.com/mac/library/documentation/Java/Conceptual/Java14Development/02-JavaDevTools/JavaDevTools.html)
tools.jar does not exist. Classes usually located here are instead included in classes.jar. Scripts that rely on the existence of tools.jar need to be rewritten accordingly.
Free Java Download For Mac
It sucks!
Solution no. 7:
How To Update Java On Mac
The easiest way is to use Homebrew.
Install Homebrew and then:
Download Java For Mac Os
You can list all available versions using the following command:brew cask search java
Solution no. 8:
Compiling with -source 1.5 -target 1.5 (in a JDK 6 environment) will honor only language elements that were in 1.5 and prior. Great. But there were no language changes in 6 anyway. Problem with this approach (on Mac with 1.6) is that using classes that came AFTER 1.5 will still compile because they exist in the rt.jar. So one could run in a 1.5 env and get a class not found exception with no prior warning when compiling. I found this out the hard way with javax.swing.event.RowSorterEvent/Listener. Both entered 'Since 1.6' but are not caught with -source 1.5
Solution no. 9:
If you installed brew, cmd below will be helpful:
As the message says, you have to go to Apple, not Sun, for Java on the Mac. As far as I know, Apple JDK 6 is installed by default on Mac OS X 10.6 (Snow Leopard). Maybe you need to install the developer tools from your Mac OS X installation DVD (the dev tools are an optional install from the OS DVD).
Do I Need To Download Java For Mac Os X 10.6
See: http://developer.apple.com/java/
NOTE This answer from 16 Oct 2009 is now outdated; you can get the JDK for Mac OS X from the regular JDK download page on Oracle's website now.
Solution no. 3:
For people using any LION OS X 10.7.X
They uploaded Java SE 6 version 1.6.0_26 available here
Solution no. 4:
I bought a MacBook Pro yesterday (Mac OS X v10.8 (Mountain Lion)) and there is no JDK installed by default…
As well as javac, I also found it didn't have packages such as SVN installed. It turns out you can get everything from the Apple developer page (you will need to register with your AppleID). SVN is part of the 'Command Line Tools' package.
This is what happens on a fresh MacBook:
Hopefully this will help out other newbies like me 😉
Solution no. 5:
Mac comes with the JDK, for more information check:
Solution no. 6:
The explanation is that JDK is a bit specific and does not contain the library tools.jar. For my development, I need this library and Mac's JDK doesn't provide it:
(Cf. http://developer.apple.com/mac/library/documentation/Java/Conceptual/Java14Development/02-JavaDevTools/JavaDevTools.html)
tools.jar does not exist. Classes usually located here are instead included in classes.jar. Scripts that rely on the existence of tools.jar need to be rewritten accordingly.
Free Java Download For Mac
It sucks!
Solution no. 7:
How To Update Java On Mac
The easiest way is to use Homebrew.
Install Homebrew and then:
Download Java For Mac Os
You can list all available versions using the following command:brew cask search java
Solution no. 8:
Compiling with -source 1.5 -target 1.5 (in a JDK 6 environment) will honor only language elements that were in 1.5 and prior. Great. But there were no language changes in 6 anyway. Problem with this approach (on Mac with 1.6) is that using classes that came AFTER 1.5 will still compile because they exist in the rt.jar. So one could run in a 1.5 env and get a class not found exception with no prior warning when compiling. I found this out the hard way with javax.swing.event.RowSorterEvent/Listener. Both entered 'Since 1.6' but are not caught with -source 1.5
Solution no. 9:
If you installed brew, cmd below will be helpful:
brew cask install java
Solution no. 10:
As of Mac OS X v10.6 (Snow Leopard), you can run Java 6 in 32-bit mode on either 32-bit or 64-bit Intel processor equipped Macs.
If you cannot upgrade to Snow Leopard, Soy Latte is a pre-compiled version of Java 6 for Intel 32-bit.