What Jdk Should I Download For Mac

Active1 year ago

I would like to use the WatchService API as mentioned in this link:http://download.oracle.com/javase/tutorial/essential/io/notification.html

If you don’t, you can download the basic software by visiting a Sun Microsystems Web site. The product that you want to download is known by a few different names. It’s called the Java Development Kit (JDK), the Java Software Development Kit (SDK), and the Java Standard Edition (Java SE). Eclipse for Java How To Install Eclipse and Get Started with Java Programming (on Windows, Mac OS and Ubuntu).

After reading around, I found out that WatchService is part of the NIO class which is scheduled for JDK 7. So, it is in beta form. It's fine.

http://jdk7.java.net/download.html has the JDK which I downloaded and extracted. I got a bunch of folders. I don't know what to do with them.

Then, I read around some more and found that some nice group of people created JDK 7 as a binary so someone like me can install it easily. It is called Open JDK:http://code.google.com/p/openjdk-osx-build/

So, I downloaded the .dmg file and install it. Then I open 'Java Preference' and see that OpenJDK7 is available.

So, now I feel that I can start trying out WatchService API. From the tutorial in the first link, the author gave a .java file to test it out first and make sure that it is running. Here is the link to the file:http://download.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java

So, I boot up Eclipse (actually I use STS) and create a new Java project and choose JaveSE-1.7 in the 'use an execution environment JRE:'. Under the src folder, I copy pasted the WatchDir.java file.

And I still see tons of squiggly red lines. All the 'import.java.nio.*' are all red and I cannot run it as a Java app.

What do I need to do?

Zoe
15.6k12 gold badges65 silver badges96 bronze badges
okysabeniokysabeni
4,21313 gold badges57 silver badges76 bronze badges

14 Answers

Ben S
58.4k25 gold badges157 silver badges206 bronze badges
MukundMukund

This is how I got 1.7 to work with Eclipse. I hope it helps.

  1. I Downloaded the latest OpenJDK 1.7 universal (32/64 bits) JDKfrom Mac OS/X branch from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
  2. copied the jdk to /Library/Java/JavaVirtualMachines/ next to thedefault 1.6.0 one
  3. In Eclipse > Preferences > Java > Installed JREs you add a new one, of type MacOS X VM, and set the home as /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home andname Java SE 7 (OpenJDK)
  4. Click Finish
  5. Set the added JRE as default

that should be it :)

What Jdk Should I Download For Macvectorsizevectorsize
1,0151 gold badge7 silver badges6 bronze badges

Years ago, Apple joined the OpenJDK project, transferring their formerly proprietary macOS-specific JVM code as free-of-cost open-source. Apple ceased distribution of their own branded JVM/JDK, relying on Oracle’s branded releases to include a version for macOS.

Oracle has recently announced their intention to bring their Oracle-branded JVM release to feature parity with the OpenJDK project, with virtually the same code base. The company even donated their previously commercial tools, Flight Recorder & Mission Control, to the OpenJDK project. This is part of the shift to a new rapid “release train” plan for predictably scheduled versioning of Java and OpenJDK. Notably, the periods for free-of-cost public updates is now shortened. See this 2017-09 announcement and this posting by Mark Reinhold.

As a result of all this, macOS users of Java have a choice of vendors for a Java implementation. At this point, at least three sources are based on OpenJDK for macOS:

  • Oracle releases of the JDK and JRE, with optional paid support.
  • Azul Systems releasing:
    • Zulu line of free-of-cost JVMs with optional paid support.
    • Zing line of commercial JVMs with special features such as an alternate garbage-collector.
  • OpenJDK source code, roll-your-own compilation & installation (perhaps not practical for most of us).

Meanwhile, IBM donated code for a JVM to the Eclipse Foundation, now housed in the OpenJ9 project. I wonder if they might support a macOS release as well, though it is too soon to tell.

Personally, I am currently using the Zulu release of Java 10.0.1 from Azul on macOS High Sierra successfully with IntelliJ 2018.2 to produce Java-backed web apps with Vaadin.

Installation/Removal

Both Oracle and Azul provide utterly easy-to-use installers to install the JVM/JDK on your Mac. Verify your installation by using the Terminal.app (or equivalent) to type and run:

You will find the Java installations in this folder at the root level of your drive (not in your home folder):

/Library/Java/JavaVirtualMachines

Each version from each vendor is found there, in a labeled nested folder. You can delete any installation simply by deleting the nested folder for that version and providing your system password when prompted.

You can download the Java Development Kit (JDK) for Java 8 for the supported versions of Mac OS X:

  • Mountain Lion (10.8.3+)
  • Mavericks (10.9)
  • Yosemite (10.10)
  • El Capitan (10.11)

Each version of JVM you install can be found here:

For more instructions and FAQ, see this Oracle Guide.

For every release of Java 7 since Update 4, a Mac version has been ready alongside the other platforms. Runs on Macs with 64-bit hardware on Lion (10.7.3+), Mountain Lion (10.8.3+), and Mavericks (10.9.x).

Oracle announced the official release of the JDK for Java SE 7 Update 4 on Mac OS X (Lion), as of 2012-04-26. No more need for the tricks discussed on this page.

Installation is simple per these instructions:

  1. Download from the usual place on the Oracle web site.
  2. Mount the DMG.
  3. Run the installer.

This release has a few limitations, most notably the lack of support for Java Web Start and the Java Plugin for web browsers. That support is expected later this year.

After installing, read the JDK for Mac ReadMe. Most importantly, if you want Java 7 to be the default, drag it to the top of the list in the Java Preferences app found in your Utilities folder.

Mac OS X easily supports multiple JVMs simultaneously. Each is now found here:

Congratulations to the Apple & Oracle teams for their achievement. This geek gets a thrill seeing Mac OS X listed as a 'Certified System Configuration'.

Tip: To start Eclipse on a Mac with only Java 7 installed, open the alias file named eclipse rather than the file named Eclipse.app.

Apple continues to supply an up-to-date implementation of Java 6 for all versions of Mac OS X up through Mountain Lion.

If you do something that requires Java, such as type 'java -version' in Terminal.app, a dialog appears offering to install Java for you. If you accept, installation happens automatically similar to other 'Software Updates' from Apple.

You will find Java installed in this location, different than Java 7 & 8:

Java 6 has reached end-of-life with Oracle as of 2013-02 (unless you have a commercial support agreement with Oracle). So you should be moving to Java 7 or 8.

In Terminal.app, type java -version to verify which version is the current default.

After installing a fresh version, you may want to visit the folder described above to delete old versions. Move the folder to the Trash, and provide your System password complete the move.

By the way, Apple provides a mailing list for developers’ technical issues related to Java on OS X.

Basil BourqueBasil Bourque
131k38 gold badges438 silver badges618 bronze badges

An easy way to install Java 7 on a Mac is by using Homebrew, thanks to the Homebrew Cask plugin (which is now installed by default).

Run this command to install Java 7:

AndrewAndrew
105k165 gold badges466 silver badges648 bronze badges

I know that some may want to smack me for re-opening old post, but if you feel so do it I just hope this may help someone else trying to set JDK 7 on Mac OS (using IntelliJ).

What I did to get this working on my machine is to:

  • followed instructions on Oracle JDK7 Mac OS X Port for general installation
  • in IntelliJ open/create new project so you can add new SDK (File > Project Structure)
  • select Platform Settings > SDKs, press '+' (plus) sign to add new SDK
  • select JSDK and navigate to /Library/Java/JavaVirtualMachines/JDK 1.7.0 Developer Preview.jdk/Contents/Home. Do not get it mistaken with /Users/YOUR_USERNAME/Library/Java/. This will link 4 JARs from 'lib' directory (dt.jar, jconsole.jar, sa-jdi.jar and tools.jar)
  • you will need also add JARs from /Library/Java/JavaVirtualMachines/JDK 1.7.0 Developer Preview.jdk/Contents/Home/jre/lib (charsets.jar, jce.jar, JObjC.jar, jsse.jar, management-agent.jar, resources.jar and rt.jar)
peter_budopeter_budo
1,4754 gold badges21 silver badges43 bronze badges

Get cask

Install java7:

(I had difficulty finding the download link of java7 on oracle website, as they're just 'recommending' java8 )

EDIT January 2018(As pointed by Ankur):

Use zulu7 cask. Zulu is a certified build of OpenJDK produced by Azul Systems that should be around for a long time (they even offer JDK6 builds still).

Jdk 7 Mac

abe312abe312

It's possible that you still need to add the JDK into Eclipse (STS). Just because the JDK is on the system doesn't mean Eclipse knows where to find it.

Go to Preferences > Java > Installed JREs

If there is not an entry for the 1.7 JDK, add it. You'll have to point Eclipse to where you installed your 1.7 JDK.

If Eclipse can't find a JRE that is 1.7 compatible, I'm guessing that it just uses your default JRE, and that's probably still pointing at Java 1.6, which would be causing your red squiggly lines.

Jon QuarfothJon Quarfoth

after installing the 1.7jdk from oracle, i changed my bash scripts to add:

and then running java -version showed the right version.

Dustin GetzDustin Getz
13.5k11 gold badges69 silver badges123 bronze badges

How about Netbeans, here is an article how to set it up with NB7:

Maybe similar steps for Eclipse.

gzgegzge

As of April 27th there is an offical Oracle release of Java SE 7u4. Download the disk image and run the installer - then see the Mac readme.

MarkMark
28.9k10 gold badges83 silver badges105 bronze badges

The instructions by peter_budo worked perfectly. I had to add the jars under /Library/Java/JavaVirtualMachines/JDK 1.7.0 Developer Preview.jdk/Contents/Home/jre/lib/ to my IntelliJ project libraries. Now it works like a charm. Note that I didn't need my IDE itself to run under 1.7; rather, I only needed to be able to compile and run against 1.7. I'll most likely continue to use Apple's JRE for running the IDE since it's probably more stable with respect to graphics routines (Swing, AWT). Like the OP, I was really keen on testing out the new NIO2 API. Looking good so far. Thanks, Peter.

user1092781user1092781

What worked for me on Lion was installing the JDK7_u17 from Oracle, then editing ~/.bash_profile to include: export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk/Contents/Home

user1015892user1015892

As of December 2017, previously posted links don't work, but JDK 7 can still be downloaded from Oracle Archives (login required):

ozren1983ozren1983
1,3831 gold badge13 silver badges29 bronze badges

I updated to Yosemite and Android Studio wouldn't clean my projects or Run them on virtual or real device because of the following error:

After some research and trouble shooting, I found that the JDK file that was being pointed to at '/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home' wasn't there; all of 'JavaVirtualMachines/1.6.0.jdk/Contents/Home' was missing from '/System/Library/Java'. So, I copied 'JavaVirtualMachines/1.6.0.jdk/Contents/Home' over from '/Library/Java/' to '/System/Library/Java/' and cha ching! I was back in business.

embersofadyingfireembersofadyingfire
2301 gold badge3 silver badges15 bronze badges

Not the answer you're looking for? Browse other questions tagged macosjavajava-7 or ask your own question.

Active7 months ago

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

Here's the message for Mac:

'Apple Computer supplies their own version of Java. Use the Software Update feature (available on the Apple menu) to check that you have the most up-to-date version of Java for your 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...

Peter MortensenJdk
14.4k19 gold badges88 silver badges117 bronze badges
ajeansonajeanson
1,3004 gold badges13 silver badges17 bronze badges

16 Answers

What Jdk Should I Download For Mac Download

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:

Cœur
21.8k10 gold badges127 silver badges178 bronze badges
Mark TyeMark Tye

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

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.

JesperJesper
160k38 gold badges267 silver badges304 bronze badges

For people using any LION OS X 10.7.X

They uploaded Java SE 6 version 1.6.0_26 available here

Roy CalderonRoy Calderon
5,3863 gold badges18 silver badges19 bronze badges

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 ;)

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
matt burnsmatt burns
18.3k5 gold badges81 silver badges95 bronze badges

Mac comes with the JDK, for more information check:

pedromarcepedromarce
4,9311 gold badge20 silver badges26 bronze badges

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.

It sucks!

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
ajeansonajeanson
1,3004 gold badges13 silver badges17 bronze badges

The easiest way is to use Homebrew. Install Homebrew and then:

You can list all available versions using the following command:brew cask search java

solomkinmvsolomkinmv
9071 gold badge13 silver badges25 bronze badges

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

EvanEvan

If you installed brew, cmd below will be helpful:

brew cask install java

PonderousPonderous

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.

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
Brian M. CarrBrian M. Carr

There are various tricky issues with having multiple versions of Java (Apple's own Java 6 and Oracle JDK 7 or even 8) on one's Mac OS X system, and using different versions for different applications. I spent some time writing up my experience of my experience of installing and configuring various versions of JDK on Mac OS X 10.9.2.

Meng LuMeng Lu
4,3977 gold badges28 silver badges39 bronze badges

I think this other Stack Overflow question could help:

It basically says that if you need to compile or execute a Java application with an older version of the JDK (for example 1.4 or 1.5), you can do it using the 1.6 because it is backwards compatible. To do it so you will need to add the parameter -source 1.5 and/or -target 1.5 in the javac options or in your IDE.

Community
FgblanchFgblanch
3,1898 gold badges31 silver badges49 bronze badges

JDK is the Java Development Kit (used to develop Java software).

JRE is the Java Runtime Environment (used to run any .jar file 'Java software').

The JDK contains a JRE inside it.

On Windows when you update Java, it updates the JRE automatically.

On Mac you do not have a JRE separated you have it, but inside the JDK, so when you update Java it will update your JRE which is inside your JDK;it doesn't install an JDK for you. You need to get it from somewhere else.

Peter Mortensen
14.4k19 gold badges88 silver badges117 bronze badges
user1477929

Check this awesome tool sdkman to manage your jdk and other jdk related tools with great ease!

e.g.

Rishikesh Darandale

What Jdk Should I Download For Mac Windows 10

Rishikesh Darandale
1,5421 gold badge9 silver badges29 bronze badges

Since most answers are out of date, here's what works as of end of 2018 under the assumption that

  1. You want to install the GPL version of OpenJDK.[0]
  2. You do not want to install Homebrew

In that case, grab the desired version from the Oracle GPLv2 OpenJDK site, or from AdoptOpenJDK (not tested by myself yet). In the below I am assuming version 11.0.1 for Mac. Then do in your favorite shell:

[0] Note that the Oracle branded JDK has significant licensing restrictions allowing you its use basically only for testing, i.e., not for production. If you do not have a support agreement with Oracle, then it seems risky to me to use their JDK, especially since the differences to OpenJDK are minimal.

LCCLCC

As a rule you cannot install other versions of Java on a Mac than those provided by Apple through Software Update. If you need Java 6 you must have a 64-bit Intel computer. You should always have Java 5 and 1.4 and perhaps 1.3 installed if you have at least OS X 10.4.

Download Java 8 Jdk For Mac

If you have VERY much elbow grease and is willing to work with beta software you can install the OpenJDK under OS X, but I don't think you want to go there.

Thorbjørn Ravn AndersenThorbjørn Ravn Andersen

Download Jdk For Mac

58.2k25 gold badges154 silver badges294 bronze badges

What Jdk Should I Download For Mac Mac

Not the answer you're looking for? Browse other questions tagged javamacosinstall or ask your own question.