CentOS Install OpenJDK

29/12/2020
When it’s necessary to build your apps or do some programming on Java, it’s always important to have all the necessary tools ready, for example, the compiler (also known as JDK – Java Development Kit) and the runtime (also known as JRE – Java Runtime Environment). Note that by default, JDK comes up with JRE, so you don’t have to manually install JRE again.

Of course, Java programs require a special environment to work on. When you compile a Java program, it generates a “jar” package that contains a universal binary form of the app. When you wish to run it, it’s the task of the JRE to read the universal binary and run it smoothly on the current system.

Linux is my favorite platform for programming, especially Java. You can work with both the Oracle Java and the OpenJDK. For Linux, I prefer the OpenJDK one as it’s more convenient on the Linux platform and almost all the major Linux distros integrate with OpenJDK easier than the Oracle counterpart.

CentOS is the open-source and community edition of the well-known and respected RHEL (Red Hat Enterprise Linux). I just got my CentOS machine ready, now I need to set OpenJDK.

Let’s go and enjoy OpenJDK!

Getting OpenJDK

There’re 2 separate ways of setting OpenJDK on CentOS – from the default CentOS repository (OpenJDK 8) and manually downloading and setting the OpenJDK (OpenJDK 11). Don’t forget to check out the latest features of Java 11!

Installing from CentOS repo

Fire up a terminal and make sure that everything is up-to-date –

su
yum update

Now, run the following command –

yum install java-1.8.0-openjdk

Installing OpenJDK manually

Note that this is not the recommended way of enjoying OpenJDK. Use the previous method unless you REALLY need the latest OpenJDK.

Using this method, you can also

Download the latest OpenJDK

Extract the downloaded OpenJDK –

tar -xfvz openjdk-11.0.1_linux-x64_bin.tar.gz –directory /usr/lib/jvm

Don’t forget to verify the extraction –

/usr/lib/jvm/jdk-11.0.1/bin/java -version

It’s time to make the switch to the newer JDK.

sudo sh -c ‘for bin in /usr/lib/jvm/jdk-11.0.1/bin/*; do update-alternatives
–install /usr/bin/$(basename $bin) $(basename $bin) $bin 100; done’

sudo sh -c ‘for bin in /usr/lib/jvm/jdk-11.0.1/bin/*; do update-alternatives
–set $(basename $bin) $bin; done’

Now, we will grab “update-alternatives” and tell the system to change to the newly set OpenJDK –

sudo update-alternatives –config java

Then, select the OpenJDK number that represents the OpenJDK 11 –

Voila! OpenJDK is now present in the system!

Don’t forget to check out the result of the change –

java –version

For Java programming, what’s better than a well-packed IDE? Check out Eclipse – one of the finest IDEs for Java programmers!

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Install OpenJDK 10 on Debian 9 Stretch

In short, Java Development Kit (JDK) is used to compile Java source code into Java byte code. Then Java Runtime Environment...
28/12/2020

Install Oracle JDK 11 on Ubuntu

The full form of JDK is Java Development Kit. It is used to write and test Java programs. Recently, JDK 11 came out. It...
29/12/2020

How to Install Java 9 on Ubuntu

Java is not included in Ubuntu by default. There are many application that do not work without Java. So, you require to...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Hướng Dẫn Chọn Dịch Vụ Thuê Địa Chỉ IPv4
10/03/2025

Reliable IPv4 and IPv6 Subnet Rental Services: The Perfect Solution for Global Businesses
23/12/2024

Tìm Hiểu Về Thuê Proxy US – Lợi Ích và Cách Sử Dụng Hiệu Quả
11/12/2024

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024