- 6 JDK Installation for Linux Platforms
- System Requirements
- JDK 8 Installation Instructions
- Installation Instructions Notation and Files
- Installation of the 64-bit JDK on Linux Platforms
- Installation of the 64-bit JDK on RPM-based Linux Platforms
- Change in Communication With the Alternatives Framework of JDK RPM Installer Starting With JDK 8u261
- Installation of the 32-bit JDK on Linux Platforms
- Installation of the 32-bit JDK on RPM-based Linux Platforms
- Installation of Public Key on RPM-based Linux Platforms
- General Installation Notes
- Root Access
- Overwriting Files
- System Preferences
- Установка Java в Ubuntu 18.04
- Какую версию Java выбрать?
- Установка Java 8 в Ubuntu 18.04
- 1. Как установить OpenJDK в Ubuntu
- 2. Как установить Oracle Java в Ubuntu
- Установка Java 11 в Ubuntu 18.04
- 1. Установка OpenJDK 11
- 2. Установка Oracle Java 11
- Выбор версии Java
- Удаление Java из Ubuntu
- Выводы
6 JDK Installation for Linux Platforms
This page describes JDK for Linux system requirements and gives installation instructions for several JDK-Linux combinations.
This page contains these topics:
See «JDK 8 and JRE 8 Installation Start Here» for general information about installing JDK 8 and JRE 8.
For information on enhancements to JDK 8 that relate to the installer, see «Installer Enhancements in JDK 8».
System Requirements
See http://www.oracle.com/technetwork/java/javase/certconfig-2095354.html for information about supported platforms, operating systems, and browsers.
On a 64-bit system, you can download either the 64-bit or the 32-bit version of the Java platform. However, if you are using a 32-bit browser and you want to use the plugin, then you need to install the 32-bit version of the Java platform. To determine which version of Firefox you are running, launch the application, and select the menu item Help -> About Mozilla Firefox. At the bottom of the window is a version string line that contains either «Linux i686» (32-bit) or «Linux x86_64» (64-bit). To setup the Java plugin, see «Manual Installation and Registration of Java Plugin for Linux».
JDK 8 Installation Instructions
This topic describes:
Installation Instructions Notation and Files
For instructions containing the notation version , substitute the appropriate JDK update version number. For example, if you are installing update JDK 8 update release 2, the following string representing the name of the bundle:
Note that, as in the preceding example, the version number is sometimes preceded with the letter u , for example, 8u2 , and sometimes it is preceded with an underbar, for example, jdk1.8.0_02 .
The following table lists the options and instructions for downloading the JDK 8 release on a Linux platform.
Download File and Instructions | Architecture (CPU Type) | Who Can Install |
---|---|---|
For Linux x64 systems: jdk-8u version -linux-x64.tar.gz «Installation of the 64-bit JDK on Linux Platforms» | Intel — 64-bit | anyone |
For Linux aarch64 (64-bit ARM) systems: jdk-8u version -linux-aarch64.tar.gz (version 8u271 and later) «Installation of the 64-bit JDK on Linux Platforms | ARM — 64-bit | anyone |
For Linux x86 systems: jdk-8u version -linux-i586.tar.gz «Installation of the 32-bit JDK on Linux Platforms» | Intel — 32-bit | anyone |
For Linux x64 systems: jdk-8u version -linux-x64.rpm «Installation of the 64-bit JDK on RPM-based Linux Platforms» | Intel — 64-bit RPM-based Linux | root |
For Linux aarch64 (64-bit ARM) systems: jdk-8u version -linux-aarch64.rpm (version 8u271 and later) «Installation of the 64-bit JDK on RPM-based Linux Platforms» | ARM — 64-bit RPM-based Linux | root |
For Linux x86 systems: jdk-8u version -linux-i586.rpm «Installation of the 32-bit JDK on RPM-based Linux Platforms» | Intel — 32-bit RPM-based Linux | root |
Installation can be performed using either of the following:
Installation of JDK using archive files ( .tar.gz ) allows you to install a private version of the JDK for the current user into any location, without affecting other JDK installations. However, it may involve manual steps to get some of the features to work (for example, the -version: release option of the java command, which allows you to specify the release to be used to run the specified class, requires the correct path to the JDK release under /usr/jdk ).
Installation of JDK using RPM packages allows you to perform a system-wide installation of the JDK for all users, and requires root access.
When you download and install the Java Development Kit (JDK), the associated Java Runtime Environment (JRE) is also installed.
JDK 7u6 and later releases include JavaFX SDK (version 2.2 or later). The JavaFX SDK and Runtime are installed and integrated into the standard JDK directory structure.
Installation of the 64-bit JDK on Linux Platforms
This procedure installs the Java Development Kit (JDK) for 64-bit Linux, using an archive file ( .tar.gz ).
These instructions use the following files:
jdk-8uversion-linux-x64.tar.gz and jdk-8uversion-linux-aarch64.tar.gz (version 8u271 and later) for 64-bit ARM systems.
Download the required file.
Before the file can be downloaded, you must accept the license agreement. The archive file can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.
Change directory to the location where you would like the JDK to be installed, then move the .tar.gz archive file to the current directory.
Unpack the archive file and install the JDK.
- For x64 — % tar zxvf jdk-8uversion-linux-x64.tar.gz
- For 64-bit ARM system — % tar zxvf jdk-8uversion-linux-aarch64.tar.gz
The Java Development Kit files are installed in a directory called jdk1.8.0_ version in the current directory.
Delete the .tar.gz file if you want to save disk space.
Installation of the 64-bit JDK on RPM-based Linux Platforms
This procedure installs the Java Development Kit (JDK) for 64-bit RPM-based Linux platforms, such as Oracle, Red Hat and SuSE, using an RPM binary file ( .rpm ) in the system location. You must be root to perform this installation.
These instructions use the following files:
jdk-8uversion-linux-x64.rpm and jdk-8uversion-linux-aarch64.rpm (version 8u271 and later) for 64-bit ARM systems.
Download the required file.
Before the file can be downloaded, you must accept the license agreement.
Become root by running su and entering the super-user password.
Uninstall any earlier installations of the JDK packages.
Install the package:
- For x64 — # rpm -ivh jdk-8uversion-linux-x64.rpm
- For 64-bit ARM system — # rpm -ivh jdk-8uversion-linux-aarch64.rpm
To upgrade a package:
- For x64 — # rpm -Uvh jdk-8uversion-linux-x64.rpm
- For 64-bit ARM system — # rpm -Uvh jdk-8uversion-linux-aarch64.rpm
Delete the .rpm file if you want to save disk space.
Exit the root shell. No need to reboot.
Starting with version 8u40, the JDK installation is integrated with the alternatives framework and after installation, the alternatives framework is updated to reflect the binaries from the recently installed JDK. Java commands such as java , javac , javadoc , and javap can be invoked from the command line.
Using the java -version command, users can confirm the default (recently installed) JDK version.
In addition, users can now check which specific RPM package provides the java files:
Change in Communication With the Alternatives Framework of JDK RPM Installer Starting With JDK 8u261
Prior to JDK 8u261, the JDK RPM installers registered two groups of symbolic links with the alternatives framework, java and javac . In some versions of the alternatives framework, certain link names in these groups were duplicated, which resulted in installation failures.
Starting with JDK 8u261, the JDK RPM doesn’t register the javac group with the alternatives framework. All links unique to the javac group are moved into the java group, but the set of symbolic links registered by the installer are not changed; only the duplicated links have been dropped.
The implication of this change is that if you install JDK 8u261 and JDK 8u251 (or older versions) and uninstall JDK 8u261, the symbolic links from the java group that are managed by the alternatives framework will be deleted. To restore the deleted links, run the following command:
Installation of the 32-bit JDK on Linux Platforms
This procedure installs the Java Development Kit (JDK) for 32-bit Linux, using an archive file ( .tar.gz ).
These instructions use the following file:
Download the file.
Before the file can be downloaded, you must accept the license agreement. The archive file can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.
Change directory to the location where you would like the JDK to be installed, then move the .tar.gz archive file to the current directory.
Unpack the archive file and install the JDK.
The Java Development Kit files are installed in a directory called jdk1.8.0_ version in the current directory.
Delete the .tar.gz file if you want to save disk space.
Installation of the 32-bit JDK on RPM-based Linux Platforms
This procedure installs the Java Development Kit (JDK) for 32-bit RPM-based Linux platforms, such as Red Hat and SuSE, using an RPM binary file ( .rpm ) in the system location. You must be root to perform this installation.
These instructions use the following file:
Download the file.
Before the file can be downloaded, you must accept the license agreement.
Become root by running su and entering the super-user password.
Uninstall any earlier installations of the JDK packages.
Install the package.
To upgrade a package:
Exit the root shell. No need to reboot.
Delete the .rpm file if you want to save disk space.
Starting with version 8u40, the JDK installation is integrated with the alternatives framework and after installation, the alternatives framework is updated to reflect the binaries from the recently installed JDK. Java commands such as java , javac , javadoc , and javap can be invoked from the command line.
Using the java -version command, users can confirm the default (recently installed) JDK version.
In addition, users can now check which specific RPM package provides the java files:
Installation of Public Key on RPM-based Linux Platforms
Since JDK version 8, the JDK RPMs are signed with OL keys. Installation of these RPMs on Linux distributions other than OL gives a warning message indicating that security validation of the package fails. This indicates that the public key used to sign this RPM needs to be installed in the system. A sample warning message and the public key installation steps are as follows:
Sample Warning Message
Installation Steps
Download the key file from https://yum.oracle.com/RPM-GPG-KEY-oracle-ol7 using the following command:
Install the key using the following command:
sudo rpm —import RPM-GPG-KEY-oracle-ol7
Public key installation needs to be done only once. The key installation is persistent across reboots.
General Installation Notes
This topic describes general installation topics.
Root Access
Installing the software automatically creates a directory called jdk1.8.0_ version . Note that if you choose to install the JDK into system-wide location, such as /usr/jdk , you must first become root to gain the necessary permissions. If you do not have root access, simply install the JDK into your home directory, or a subdirectory that you have permission to write to.
Overwriting Files
If you install the software in a directory that contains a subdirectory named jdk1.8.0_ version , the new software overwrites files of the same name in that jdk1.8.0_ version directory. Please be careful to rename the old directory if it contains files you would like to keep.
System Preferences
By default, the installation script configures the system such that the backing store for system preferences is created inside the JDK’s installation directory. If the JDK is installed on a network-mounted drive, it and the system preferences can be exported for sharing with Java runtime environments on other machines.
Источник
Установка Java в Ubuntu 18.04
Java — это очень популярный язык программирования, разработанный в компании Sun Microsystems. Сейчас Java используется для создания различных десктопных программ, веб-приложений, серверных приложений и многого другого. Основная особенность этого языка — это максимальная кроссплатформенность. Программа, написанная для одной системы, будет без проблем работать в другой. Но для программ, написанных на Java, нужна специальная Java-машина. Именно её мы будем сегодня устанавливать.
В этой статье мы рассмотрим, как выполняется установка Java Ubuntu 18.04 для разных версий программы. А также попытаемся разобраться во всём её многообразии.
Какую версию Java выбрать?
Сейчас разработкой Java занимается компания Oracle. До недавнего времени существовало две основных версии виртуальной машины Java:
- Старая седьмая версия;
- Новая восьмая, используемая в большинстве программ.
Платформа распространялась в двух форматах:
- Проприетарном (Oracle Java) — с дополнительными возможностями и поддержкой;
- Открытом (Open JDK) — полностью открытая версия.
Обе платформы выпускались компанией Oracle, но вторая поддерживалась сообществом разработчиков, а первая самой компанией. Сейчас же ситуация немного изменилась. Теперь компания выпускает новую версию Java каждые пол года. Сначала вышла Java 9, 10, а затем 11 и длительность срока поддержки этих версий тоже короткая — всего семь месяцев. Поэтому большинство программ остались работать на Java 8, которая будет официально поддерживаться до 2020 года. Именно её и надо устанавливать в большинстве случаев.
Если вы разработчик, и хотите получить самую свежую версию Java, то стоит устанавливать Java 11. Это LTS-версия, которая будет поддерживаться до 2026 года. В ней было очень много улучшений и изменений, как в плане синтаксиса, так и для распространения. Теперь проприетарная версия доступна бесплатно только для некоммерческого использования. Для коммерческих целей необходимо платить или же устанавливать OpenJDK.
В Ubuntu, да и в других дистрибутивах Java поставляется в двух редакциях:
- JDK или Java Development Kit — содержит полную версию Java, необходимую для разработки на этом языке;
- JRE или Java Runtime Environment — содержит только окружение для выполнения программ.
Здесь, я думаю, надо выбирать то, что вам нужно. Если нет необходимость что-то компилировать на Java, то будет достаточно JRE. А теперь перейдём к установке.
Установка Java 8 в Ubuntu 18.04
1. Как установить OpenJDK в Ubuntu
Если вы хотите установить OpenJDK в Ubutnu, то никаких сторонних репозиториев вам не нужно. Восьмая версия платформы есть в официальном репозитории Ubuntu 18.04. Чтобы установить jdk на Ubuntu используйте:
sudo apt install openjdk-8-jdk
Для установки JRE в Ubuntu выполните:
sudo apt install openjdk-8-jre
После этого вы можете проверить версию Java:
2. Как установить Oracle Java в Ubuntu
К сожалению с недавнего времени репозиторий от Webupdteam работать перестал и теперь единственный рабочий способ получить самую свежую версию java — скачать её из официального сайта. На странице надо отметить галочку Accept License:
Затем вас перенаправит на страницу входа, необходимо войти в свою учетную запись Oracle или создать новую, только после этого начнется загрузка выбранной версии. После завершения загрузки создайте папку /usr/lib/jvm/:
sudo mkdir /usr/lib/jvm/
Затем распакуйте в неё полученный архив:
sudo tar -zxvf jdk-8u221-linux-x64.tar.gz -C /usr/lib/jvm/
Добавьте исполняемый файл java к списку утилиты управления версиями:
sudo update-alternatives —install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_221/bin/java 3
Затем активируйте эту версию:
sudo update-alternatives —config java
Некоторым приложениям нужен путь к исполняемым файлам Java в переменных окружения. Создайте файл /etc/profile.d/javajdk.sh со следующим содержимым:
sudo vi /etc/profile.d/java8jdk.sh
export PATH=$PATH:/usr/lib/jvm/jdk1.8.0_221/bin
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_221/
export JRE_HOME=/usr/lib/jvm/jdk1.8.0_221/jre/
export J2SDKDIR=/usr/lib/jvm/jdk1.8.0_221/
export J2REDIR=/usr/lib/jvm/jdk1.8.0_221/jre/
Чтобы загрузить эти переменные выполните:
После этого проверьте правильность установки, посмотрев версию:
Установка Java 11 в Ubuntu 18.04
1. Установка OpenJDK 11
Java 11 — это последняя на данный момент версия Java. Это версия с длительным сроком поддержки, поэтому она будет поддерживаться до 2026 года. Свободная версия есть в официальных репозиториях, поэтому вы можете её оттуда без проблем установить:
sudo apt install openjdk-11-jdk
Или же вы можете установить JRE-редакцию только для запуска программ:
sudo apt install openjdk-11-jre
Далее вы можете посмотреть версию:
2. Установка Oracle Java 11
Для установки этой версии программы необходимо добавить уже другой репозиторий:
sudo add-apt-repository ppa:linuxuprising/java
Затем запустите скрипт установщика. Он скачает пакет с сайта и установит его на ваш компьютер. Вам нужно будет только принять лицензию:
sudo apt install oracle-java11-installer
Проверьте версию Java:
Выбор версии Java
Если вы установили несколько версий Java в систему, то вам нужно выбрать, какая из них будет использоваться по умолчанию. Для этого используется утилита update-java-alternatives. Для просмотра списка версий выполните:
sudo update-java-alternatives —list
Затем установите нужную версию с помощью опции —set:
sudo update-java-alternatives —set oracle-java-8
Удаление Java из Ubuntu
Чтобы удалить ненужную больше версию Java, используйте такую же команду, которую использовали для установки, только с опцией purge:
sudo apt purge oracle-java11-installer
sudo apt purge openjdk-11*
sudo apt purge openjdk-8*
Затем вы можете удалить PPA-репозиторий:
sudo add-apt-repository —remove ppa:linuxuprising/java
Чтобы удалить java 8 надо удалить папку, в которую вы её распаковали:
sudo rm -Rf /usr/lib/jvm/jdk1.8.0_221/
Выводы
В этой статье мы разобрали, как установить Java на Ubuntu 18.04. Я думаю, теперь вы знаете, какая версия вам нужна и как всё правильно установить. Надеюсь, информация из статьи была вам полезной.
Источник