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

Java 10 New Features

What’s New in Java 10 and What are the Future Plans? Recently Java has changed the pace of releases. Previously, it would...
28/12/2020

Installing JDK on Debian 10

Java Development Kit or JDK in short is used to develop and run Java applications. There are two variants of JDK, a) OpenJDK...
29/12/2020

Install Oracle JDK 10 on Ubuntu 18.04 LTS

How to Install Oracle JDK 10 on Ubuntu 18.04 Oracle JDK is used by Java developers to develop and test Java programs. It...
28/12/2020
Bài Viết

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

SỰ KHÁC BIỆT GIỮA RESIDENTIAL PROXY VÀ PROXY DATACENTER
17/02/2024

Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail
07/01/2024

Mua shadowsocks và hướng dẫn sữ dụng trên window
05/01/2024

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?
04/01/2024

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo
02/01/2024