- Как вручную установить Oracle Java на Debian или Ubuntu
- Распаковка архива
- Перенос в распакованной папки в /opt
- Установка jdk-9.0.4 и javac в системе по умолчанию
- Проверяем нашу установку
- О песочнице
- О модерации
- Java Downloads
- JDK Development Kit 20.0.1 downloads
- Release information
- JDK Development Kit 17.0.7 downloads
- Release information
- GraalVM for JDK 20.0.1 downloads
- Release information
- GraalVM for JDK 17.0.7 downloads
- Release information
- Protect your investment—and more
- Java SE subscribers have more choices
- Java SE Development Kit 8u371
- JRE 8
- Server JRE 8
- Which Java 8 package do I need?
- Release information
- How To Install Java JDK on Debian 11
- OpenJDK or Oracle Java
- Install Java on Debian 11
- Install OpenJDK
- Install OpenJDK JDK
- Install OpenJDK JRE
- Install Oracle Java
- Download Oracle Java
- Install Oracle Java JDK/JRE
- Set Default Java Version
- Verify Java Version
- Setup Environmental Variables
- Conclusion
Как вручную установить Oracle Java на Debian или Ubuntu
Меня часто спрашивают о том, как же установить JDK на ос Линукс, чаще всего это дистрибутив Ubuntu или же другие дистрибутивы основанные на Debian.
Так же у многих в последнее время возникает проблема с установкой JDK через терминал с помощью apt-get install в связи с разного рода ошибками. Чтобы не мучаться с их устранением можно установить java в ручную, так на мой взгляд и лучше и быстрее.
Не Буду томить давайте приступим.
Первое что мы делаем это качаем архив JDK с Oracle.com, на момент написания статьи версия jdk-9.0.4
И так вот шаги которые мы должны выполнить
1) распаковка скачанного архива
2) перенести распакованную jdk в папку /opt/
3) установить jdk-9.0.4 и javac по умолчанию
Распаковка архива
видим, что в папке Загрузок появилась новая папка jdk-9.0.4
Перенос в распакованной папки в /opt
и так, осталось совсем не много.
Установка jdk-9.0.4 и javac в системе по умолчанию
Проверяем нашу установку
в окне терминала должно выдать, что-то вроде этого
java — auto mode
link best version is /opt/jdk-9.0.4/bin/java
link currently points to /opt/jdk-9.0.4/bin/java
link java is /usr/bin/java
/opt/jdk-9.0.4/bin/java — priority 100
так же можем проверить версию java командой
Поздравляю! вы установили java на linux в ручную.
Данная статья не подлежит комментированию, поскольку её автор ещё не является полноправным участником сообщества. Вы сможете связаться с автором только после того, как он получит приглашение от кого-либо из участников сообщества. До этого момента его username будет скрыт псевдонимом.
О песочнице
Это «Песочница» — раздел, в который попадают дебютные публикации пользователей, желающих стать полноправными участниками сообщества.
Если у вас есть приглашение, отправьте его автору понравившейся публикации — тогда её смогут прочитать и обсудить все остальные пользователи Хабра.
Чтобы исключить предвзятость при оценке, все публикации анонимны, псевдонимы показываются случайным образом.
О модерации
- рекламные и PR-публикации
- вопросы и просьбы (для них есть Хабр Q&A);
- вакансии (используйте Хабр Карьеру)
- статьи, ранее опубликованные на других сайтах;
- статьи без правильно расставленных знаков препинания, со смайликами, с обилием восклицательных знаков, неоправданным выделением слов и предложений и другим неуместным форматированием текста;
- жалобы на компании и предоставляемые услуги;
- низкокачественные переводы;
- куски программного кода без пояснений;
- односложные статьи;
- статьи, слабо относящиеся к или не относящиеся к ней вовсе.
Java Downloads
JDK 20 is the latest release of Java SE Platform and JDK 17 LTS is the latest long-term support release for the Java SE platform.
JDK Development Kit 20.0.1 downloads
JDK 20 binaries are free to use in production and free to redistribute, at no cost, under the Oracle No-Fee Terms and Conditions.
JDK 20 will receive updates under these terms, until September 2023 when it will be superseded by JDK 21.
Release information
JDK Development Kit 17.0.7 downloads
JDK 17 binaries are free to use in production and free to redistribute, at no cost, under the Oracle No-Fee Terms and Conditions.
JDK 17 will receive updates under these terms, until September 2024, a year after the release of the next LTS.
Release information
GraalVM for JDK 20.0.1 downloads
GraalVM for JDK 20 binaries are free to use in production and free to redistribute, at no cost, under the GraalVM Free Terms and Conditions.
GraalVM for JDK 20 will receive updates under these terms, until September 2023 when it will be superseded by GraalVM for JDK 21.
Oracle GraalVM uses the Graal just-in-time compiler and includes the Native Image feature as optional early adopter technology.
Native Image is extensively tested and supported for use in production, but is not a conformant implementation of the Java Platform. GraalVM for JDK 20 without the Native Image feature included is available for customers at My Oracle Support.
Release information
GraalVM for JDK 17.0.7 downloads
GraalVM for JDK 17 binaries are free to use in production and free to redistribute, at no cost, under the GraalVM Free Terms and Conditions.
GraalVM for JDK 17 will receive updates under these terms, until September 2024, a year after the release of the next LTS.
Oracle GraalVM uses the Graal just-in-time compiler and includes the Native Image feature as optional early adopter technology.
Native Image is extensively tested and supported for use in production, but is not a conformant implementation of the Java Platform. GraalVM for JDK 17 without the Native Image feature included is available for customers at My Oracle Support.
Release information
Script-friendly Download URLs
The URLs listed above will remain the same for update releases to allow their use in scripts.
Protect your investment—and more
Java SE subscribers get support for JDK 17, receive updates until at least October 2029, are entitled to GraalVM Enterprise, Java Management Service, and bundled patch releases (BPRs) with fixes not yet available to nonsubscribers, and more.
Java SE subscribers have more choices
Also available for development, personal use, and to run other licensed Oracle products.
Java SE Development Kit 8u371
Java SE subscribers will receive JDK 8 updates until at least December 2030.
The Oracle JDK 8 license changed in April 2019
The Oracle Technology Network License Agreement for Oracle Java SE is substantially different from prior Oracle JDK 8 licenses. This license permits certain uses, such as personal use and development use, at no cost — but other uses authorized under prior Oracle JDK licenses may no longer be available. Please review the terms carefully before downloading and using this product. FAQs are available here.
Commercial license and support are available for a low cost with Java SE Universal Subscription.
Java SE 8u371 checksums and GPG Keys for RPMs
JRE 8
Java SE Runtime Environment 8u371
Server JRE 8
Server JRE (Java SE Runtime Environment) 8u371
Which Java 8 package do I need?
Software developers: Java SE Development Kit (JDK) For Java developers. Includes a complete JRE plus tools for developing, debugging, and monitoring Java applications.
Running headless Linux workloads at or near your systems’ CPU or memory limits Enterprise Performance Pack brings significant memory and performance improvements including modern garbage collection algorithms, reduced memory usage and many other optimizations. Learn more
Administrators running applications on a server Server Java Runtime Environment (Server JRE). For deploying Java applications on servers. Includes tools for JVM monitoring and tools commonly required for server applications, but does not include browser integration (Java plug-in), auto-update, or an installer. Learn more
End user running Java on a desktop: Java Runtime Environment (JRE) Covers most end-users needs. Contains everything required to run Java applications on your system.
Release information
How To Install Java JDK on Debian 11
The Java JDK (Java Development Kit) is a software development environment used for developing Java Applications. The JDK is a collection of programming tools, notably JRE (Java Runtime Environment), Java (Loader for Java Application), Javac (Compiler), Jar (Archiver), etc.
On the other hand, we have JRE (Java Runtime Environment), including all components required to run programs written in the Java programming language.
OpenJDK or Oracle Java
OpenJDK is an open-source implementation of Oracle’s proprietary Java Development Kit (JDK). Oracle develops Oracle Java SE, whereas the OpenJDK is now developed by Oracle Corporation, OpenJDK and Java Community, Red Hat, IBM, Azul Systems, Apple Inc, and SAP SE.
There is no technical difference between OpenJDK and Oracle JDK.
Install Java on Debian 11
Install OpenJDK or Oracle Java as per your requirement.
You can have multiple versions of Java (OpenJDK and Oracle Java) on your system. But, you can have only one default version.
Install OpenJDK
Installing OpenJDK in Debian is a pretty straightforward process. You can use the apt command to install OpenJDK.
Install OpenJDK JDK
### Default Java JDK ### sudo apt install -y default-jdk ### Java JDK 11 ### sudo apt install -y openjdk-11-jdk
Install OpenJDK JRE
### Default JRE ### sudo apt install -y default-jre ### Java JRE 11 ### sudo apt install -y openjdk-11-jre
Install Oracle Java
There is no separate JRE (Java Runtime Environment) anymore in Oracle Java. Instead, Oracle JDK now provides JRE as well.
Download Oracle Java
You can either use the command line or browser to download Oracle Java.
Go to the Oracle JDK page to download packages using the browser. Then, download the Debian binary package for easy installation.
Oracle Java JDK 12:
Oracle Java JDK 11 (LTS):
Oracle Java JDK 8:
If you still want to use the command line, use the below command.
### Oracle Java JDK 16 ### wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/16.0.2%2B7/d4a915d82b4c4fbb9bde534da945d746/jdk-16.0.2_linux-x64_bin.deb ### Oracle Java JDK 11 ### wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/11.0.12%2B8/f411702ca7704a54a79ead0c2e0942a3/jdk-11.0.12_linux-x64_bin.deb ### Oracle Java JDK 8 ### wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u301-b09/d3c52aa6bfa54d3ca74e617f18309292/jdk-8u301-linux-x64.tar.gz
Install / Extract the downloaded Oracle Java package.
### Oracle JAVA JDK 16 ### sudo apt install -y ./jdk-16.0.2_linux-x64_bin.deb ### Oracle JAVA JDK 11 ### sudo apt install -y ./jdk-11.0.12_linux-x64_bin.deb ### Oracle JAVA JDK 8 ### sudo mkdir -p /usr/lib/jvm/ sudo tar -zxvf jdk-8u301-linux-x64.tar.gz -C /usr/lib/jvm/
Install Oracle Java JDK/JRE
Run update-alternatives commands to install Java on your system.
### Oracle Java 16 ### sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-16.*/bin/java 1 ### Oracle Java 11 ### sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-11.*/bin/java 2 ### Oracle Java 8 ### sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.*/bin/java 3
Set Default Java Version
Use the alternatives command to set the default java version.
sudo update-alternatives --config java
Select Java:
If your system has multiple Java versions, then the command would list all Java versions like below.
There are 4 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode 2 /usr/lib/jvm/jdk-11.0.12/bin/java 2 manual mode 3 /usr/lib/jvm/jdk-16.0.2/bin/java 1 manual mode * 4 /usr/lib/jvm/jdk1.8.0_301/bin/java 3 manual mode Press to keep the current choice[*], or type selection number: 1
Enter the number below the selection column to set the default Java version.
Here, I chose 1 for OpenJDK 11.
Verify Java Version
Check the java version using the following command.
openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment (build 11.0.12+7-post-Debian-2) OpenJDK 64-Bit Server VM (build 11.0.12+7-post-Debian-2, mixed mode, sharing)
The output may vary depending upon the package and the version you chose to be the default Java version.
Setup Environmental Variables
Java applications often require JAVA environment variables to be set in the system. For example, to run Java programs from anywhere, you need to set $JAVA_HOME and other variables to match your version of Java.
Create a new file under /etc/profile.d directory.
sudo nano /etc/profile.d/java.sh
Set variables based on the Java location and version for all users.
export PATH=$PATH:/usr/lib/jvm/jdk-11.0.12/bin/ export JAVA_HOME=/usr/lib/jvm/jdk-11.0.12/
To set the environment variables for a specific user, place the above variables in the ~/.bash_profile file.
Load the environments into the current session.
Conclusion
I hope this post helped you install Java on Debian 11. Java is a must to run Tomcat, Gradle, ELK Stack, Graylog, Eclipse IDE, Hadoop, etc.