Installation of the JDK on macOS
发布时间:2026-09-20 | 浏览:2
5 Installation of the JDK on macOS
The JDK supports both Intel-based (x64) and Apple Silicon (AArch64) Mac computers.
This topic includes the following sections:
System Requirements for Installing the JDK on macOS
System Requirements for Installing the JDK on macOS
JDK Installation Instruction Notation for macOS
JDK Installation Instruction Notation for macOS
Determining the Default JDK Version on macOS
Determining the Default JDK Version on macOS
Installing the JDK on macOS
Installing the JDK on macOS
Uninstalling the JDK on macOS
Uninstalling the JDK on macOS
Installation FAQ for macOS
Installation FAQ for macOS
System Requirements for Installing the JDK on macOS
JDK Installation Instruction Notation for macOS
JDK installers now support only one version of any Java feature release. You can't install multiple versions of the same feature release.
JDK is installed in /Library/Java/JavaVirtualMachines/jdk- <FEATURE> .jdk where <FEATURE> is the feature release number. For example, JDK 17 .0.1 is installed in /Library/Java/JavaVirtualMachines/jdk- 17 .jdk .
macOS x64 systems:
jdk- <FEATURE> _macos-x64_bin.dmg OR
jdk- <FEATURE> _macos-x64_bin.tar.gz
macOS aarch64 (64-bit ARM) systems:
jdk- <FEATURE> _macos-aarch64_bin.dmg OR
jdk- <FEATURE> _macos-aarch64_bin.tar.gz
Determining the Default JDK Version on macOS
When starting a Java application through the command line, the system uses the default JDK.
You can determine which version of the JDK is the default by entering java -version in a Terminal window. If the installed version is 17 Interim 0, Update 0, and Patch 0, then you see a string that includes the text 17 . For example:
To run a different version of Java, either specify the full path, or use the java_home tool. For example:
$ /usr/libexec/java_home -v 17 --exec javac -version
Installing the JDK on macOS
Download the required JDK .dmg or file from .tar.gz page: macOS x64 systems: jdk- <FEATURE> _macos-x64_bin.dmg OR jdk- <FEATURE> _macos-x64_bin.tar.gz macOS aarch64 (64-bit ARM) systems: jdk- <FEATURE> _macos-aarch64_bin.dmg OR jdk- <FEATURE> _macos-aarch64_bin.tar.gz Click Accept License Agreement .
macOS x64 systems: jdk- <FEATURE> _macos-x64_bin.dmg OR jdk- <FEATURE> _macos-x64_bin.tar.gz
macOS aarch64 (64-bit ARM) systems: jdk- <FEATURE> _macos-aarch64_bin.dmg OR jdk- <FEATURE> _macos-aarch64_bin.tar.gz
Click Accept License Agreement .
From either the browser Downloads window or from the file browser, double-click the .dmg file to start it. A Finder window appears that contains an icon of an open box and the name of the .pkg file.
Double-click the JDK 17 .pkg icon to start the installation application. The installation application displays the Introduction window.
Click Continue . The Installation Type window appears.
Click Install . A window appears that displays the message: Installer is trying to install new software. Enter your password to allow this.
Enter the Administrator user name and password and click Install Software . The software is installed and a confirmation window is displayed.
Uninstalling the JDK on macOS
Do not attempt to uninstall Java by removing the Java tools from /usr/bin . This directory is part of the system software and any changes will be reset by Apple the next time that you perform an update of the OS.
Go to /Library/Java/JavaVirtualMachines .
Remove the directory whose name matches the following format by executing the rm command as a root user or by using the sudo tool: /Library/Java/JavaVirtualMachines/jdk- 17 . interim.update.patch .jdk For example, to uninstall 17 Interim 0 Update 0 Patch 0: $ rm -rf jdk- 17 .jdk
For example, to uninstall 17 Interim 0 Update 0 Patch 0:
$ rm -rf jdk- 17 .jdk
Installation FAQ for macOS
This topic provides answers for the following frequently asked questions about installing JDK on macOS computers.
1. How do I find out which version of Java is the system default?
When you run a Java application from the command line, it uses the default JDK. If you do not develop Java applications, then you do not need to worry about this. See Determining the Default JDK Version on macOS .
2. How do I uninstall Java?
See Uninstalling the JDK on macOS .
3. After installing Java for macOS 2012-006, can I continue to use Apple's Java 6 alongside the macOS JDK for Java 17 ?
If you want to continue to develop with Java 6 using command-line, then you can modify the startup script for your favorite command environment. For bash, use this:
$ export JAVA_HOME=`/usr/libexec/java_home -v 17`
Some applications use /usr/bin/java to call Java. After installing Java for macOS 2012-006, /usr/bin/java will find the newest JDK installed, and will use that for all of the Java-related command-line tools in /usr/bin . You may need to modify those applications to find Java 6, or contact the developer for a newer version of the application.
4. What happened to the Java Preferences app in Application Utilities?
The Java Preferences app was part of the Apple Java installation and is not used by Oracle Java. Therefore, macOS releases from Apple that do not include Apple Java will not include Java Preferences.