Как установить jdk на mac os
This topic includes the following sections:
- System Requirements for Installing the JDK on macOS
- Determining the Default JDK Version on macOS
- Installing the JDK on macOS
- Uninstalling the JDK on macOS
- Installation FAQ on macOS Platform
System Requirements for Installing the JDK on macOS
The following are the system requirements for installing the JDK on macOS:
- Any Intel-based computer running macOS.
- Administrator privileges. You cannot install Java for a single user. Installing the JDK on macOS is performed on a systemwide basis for all users. Administrator privileges are required to install the JDK on macOS.
Determining the Default JDK Version on macOS
When starting a Java application through the command line, the system uses the default JDK.
There can be multiple JDKs installed on the macOS system.
You can determine which version of the JDK is the default by entering java -version in a Terminal window. If the installed version is 15 Interim 0, Update 0, and Patch 0, then you see a string that includes the text 15 . For example:
$ java -version java version "15" Java(TM) SE Runtime Environment (build 15) Java HotSpot(TM) 64-Bit Server VM (build 23.2-b04, mixed mode)
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 15 —exec javac -version
Installing the JDK on macOS
To install the JDK on macOS:
- Download the JDK .dmg file, jdk- 15 . interim.update.patch _osx-x64_bin.dmg from Java SE Downloads page.
Click Accept License Agreement .
A Finder window appears that contains an icon of an open box and the name of the .pkg file.
The installation application displays the Introduction window.
The Installation Type window appears.
A window appears that displays the message: Installer is trying to install new software. Enter your password to allow this.
The software is installed and a confirmation window is displayed.
After the software is installed, you can delete the .dmg file if you want to save disk space.
Uninstalling the JDK on macOS
To uninstall the JDK on macOS:
You must have Administrator privileges.
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- 15 . interim.update.patch .jdk For example, to uninstall 15 Interim 0 Update 0 Patch 0: $ rm -rf jdk- 15 .jdk
Installation FAQ on macOS Platform
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?
3. After installing Java for macOS 2012-006, can I continue to use Apple’s Java 6 alongside the macOS JDK for Java 15 ?
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 14`
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.
Как установить JDK (Java Development Kit) на Mac OS X
В создании этой статьи участвовала наша опытная команда редакторов и исследователей, которые проверили ее на точность и полноту.
Команда контент-менеджеров wikiHow тщательно следит за работой редакторов, чтобы гарантировать соответствие каждой статьи нашим высоким стандартам качества.
Количество просмотров этой статьи: 21 249.
В этой статье:
Если на компьютере Mac установить Java Development Kit (JDK), можно писать и компилировать программы на языке Java. Установить JDK очень просто, причем также будет установлена среда разработки NetBeans, в которой вы будете писать код и компилировать его для тестирования.
Часть 1 из 2:
Как установить JDK
![]()
Откройте страницу загрузки JDK. Запустите веб-браузер и перейдите на страницу oracle.com/downloads/index.html .
![]()
- Нажмите «Java».
- Щелкните по «Java SE».
- Нажмите «Download» (Скачать) рядом с «JDK 8 with NetBeans».
- Установите флажок у «Accept License Agreement» (Принять лицензионное соглашение), а затем нажмите ссылку у «Mac OS X» в верхней части страницы. Это самый последний выпуск Java SDK со средой разработки NetBeans.
![]()
Дважды щелкните по скачанному DMG-файлу. Откроется окно установщика JDK.
![]()
Следуйте инструкциям на экране, чтобы установить JDK. Вам будет предложено ввести пароль администратора.
![]()
Удалите DMG-файл, когда установка будет завершена (если хотите). Так вы освободите место на диске, потому что этот файл вам больше не понадобится. [1] X Источник информации
Часть 2 из 2:
Как создать первую программу
Запустите NetBeans из папки «Программы». Это среда разработки для Java, в которой можно писать программы и компилировать их.
![]()
Нажмите «File» (Файл) > «New project» (Новый проект). В NetBeans будет создан новый проект.
![]()
Выберите категорию «Java» и проект «Java Application» (Java-приложение). NetBeans будет настроена на создание Java-файлов для этого проекта.
![]()
Присвойте проекту имя и нажмите «Finish» (Готово). Например, назовите проект «ПриветМир». Откроется редактор кода.
![]()
Найдите строку «// TODO code application goes here» (Код вводить здесь). Программный код будет находиться под этой строкой.
![]()
![]()
Введите код программы с новой строки. Нажмите ⏎ Return в конце строки «// TODO code application goes here», чтобы перейти на новую строку с тем же отступом. Введите следующий код:
System.out.println("Привет, мир!");
Нажмите кнопку «Run Project» (Запустить проект). Она выглядит как зеленая кнопка воспроизведения и находится на панели инструментов.
![]()
Перейдите на вкладку «Output» (Результат), чтобы просмотреть, как работает программа. Результат можно увидеть в нижней части экрана после запуска проекта.
![]()
Исправьте ошибки. Если у проекта нет ошибок, на вкладке «Оutput» вы увидите «Привет, мир!» и слова «Build successful» (Программа работает нормально). Если в проекте есть ошибки, вы увидите, в каких строках они встречаются. [2] X Источник информации
![]()
![]()
Продолжите изучение Java. Теперь, когда вы установили JDK, продолжите изучать программирование на языке Java. Прочитайте эту статью о том, как написать первую программу на Java.
Дополнительные статьи
![]()
открыть файл «exe» в Mac OS
![]()
просмотреть историю браузера на компьютере Mac
![]()
подключить внешний жесткий диск к Macbook Pro
![]()
открывать приложения на Mac с правами суперпользователя
![]()
вызвать командную строку на Mac
![]()
запускать приложения через терминал в Maс OS
![]()
установить программы от неизвестных разработчиков на Mac
![]()
пинговать в Mac OS
![]()
посмотреть Звездные Войны в Командной строке
![]()
записывать информацию на внешний жесткий диск на Mac OSX
узнать свой IP–адрес на Мас
![]()
отключить ввод пароля на Mac
![]()
изменить направление прокрутки на компьютере Mac
![]()
обновить Safari на Mac
- ↑https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html
- ↑http://www.macworld.co.uk/how-to/mac/learn-set-up-java-programming-environment-in-os-x-3636924/
Об этой статье
Штатный автор wikiHow
В создании этой статьи участвовала наша опытная команда редакторов и исследователей, которые проверили ее на точность и полноту.
Команда контент-менеджеров wikiHow тщательно следит за работой редакторов, чтобы гарантировать соответствие каждой статьи нашим высоким стандартам качества. Количество просмотров этой статьи: 21 249.
Установка и расположение Java на Mac OS X
Часто возникает ситуация, когда после загрузки и установки Java на операционной системе Mac OS X, разработчику требуется узнать точное расположение установленного программного обеспечения. Это может быть необходимо для выполнения программирования на языке JNI или для других задач, связанных с настройкой или использованием Java.
Обычно предполагается, что после установки Java создается специальная папка, например, 1.7.0.jdk в директории /Library/Java/JavaVirtualMachines/ . Однако, в некоторых случаях, после выполнения команды ls /Library/Java/JavaVirtualMachines/ в терминале, разработчик обнаруживает, что указанная директория пуста. Поиск по системе также не дает результатов, что создает путаницу относительно местоположения Java.
На самом деле, Java устанавливается в системную директорию, которую можно найти, выполнив следующую команду в терминале:
/usr/libexec/java_home
Выполнение этой команды выведет путь к домашней директории Java, который обычно выглядит следующим образом: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Таким образом, несмотря на первоначальные предположения, Java устанавливается не в папке /Library/Java/JavaVirtualMachines/ , а в домашней директории Java, что подтверждается выполнением команды /usr/libexec/java_home .
Это знание поможет избежать путаницы и ошибок при выполнении задач, связанных с использованием и настройкой Java в операционной системе Mac OS X.
Как установить jdk на mac os
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
- JDK Installation Instruction Notation for macOS
- Determining the Default JDK Version on macOS
- Installing the JDK on macOS
- Uninstalling the JDK on macOS
- Installation FAQ for macOS
System Requirements for Installing the JDK on macOS
For supported processors and browsers, see Oracle JDK Certified Systems Configurations.
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.
For example, you can’t install jdk- 20 and jdk- 20 .0.1 simultaneously. If you attempt to install jdk- 20 .0.1 after jdk- 20 is installed, the installer uninstalls jdk- 20 and installs jdk- 20 .0.1 .
If you install an older version of a JDK when the newer version of the same feature family already exists, an error is displayed, prompting you to uninstall a newer JDK version if an older version has to be installed.
JDK is installed in /Library/Java/JavaVirtualMachines/jdk- .jdk where is the feature release number. For example, JDK 20 .0.1 is installed in /Library/Java/JavaVirtualMachines/jdk- 20 .jdk .
macOS x64 systems:
- jdk- _macos-x64_bin.dmg OR
- jdk- _macos-x64_bin.tar.gz
This string becomes:
jdk-20_macos-x64_bin.dmg
jdk-20_macos-x64_bin.tar.gz
macOS aarch64 (64-bit ARM) systems:
- jdk- _macos-aarch64_bin.dmg OR
- jdk- _macos-aarch64_bin.tar.gz
This string becomes:
jdk-20_macos-aarch64_bin.dmg
jdk-20_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.
There can be multiple JDKs installed on the macOS system.
You can determine which version of the JDK is the default by entering java -version in a Terminal window. If the installed version is 20 Interim 0, Update 0, and Patch 0, then you see a string that includes the text 20 . For example:
$ java -version java version "20" Java(TM) SE Runtime Environment (build 20) Java HotSpot(TM) 64-Bit Server VM (build 23.2-b04, mixed mode)
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 20 —exec javac -version
Installing the JDK on macOS
To install the JDK on macOS:
- Download the required JDK .dmg or file from .tar.gz page:
- macOS x64 systems: jdk- _macos-x64_bin.dmg OR jdk- _macos-x64_bin.tar.gz
- macOS aarch64 (64-bit ARM) systems: jdk- _macos-aarch64_bin.dmg OR jdk- _macos-aarch64_bin.tar.gz
Click Accept License Agreement .
A Finder window appears that contains an icon of an open box and the name of the .pkg file.
The installation application displays the Introduction window.
The Installation Type window appears.
A window appears that displays the message: Installer is trying to install new software. Enter your password to allow this.
The software is installed and a confirmation window is displayed.
After the software is installed, you can delete the .dmg or .tar.gz file if you want to save disk space.
Uninstalling the JDK on macOS
To uninstall the JDK on macOS:
You must have Administrator privileges.
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- 20 . interim.update.patch .jdk For example, to uninstall 20 Interim 0 Update 0 Patch 0: $ rm -rf jdk- 20 .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?
3. After installing Java for macOS 2012-006, can I continue to use Apple’s Java 6 alongside the macOS JDK for Java 20 ?
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 20 `
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.