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

How to Install JDK 12 on Arch Linux

Java Development Kit (JDK) is used to compile, run, debug, and sign Java applications. It is used by Java developers all...
29/12/2020

Install Oracle JDK 9 on CentOS7

JDK or Java Development Kit is used by Java programmers all over the world to compile and run Java code. Java and JDK is...
28/12/2020

Eclipse Java Tutorial

Eclipse Integrated Development Environment is an incredible open source compilation of tools, projects and co-existing working...
28/12/2020
Bài Viết

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

Mua proxy v4 chạy socks5 để chơi game an toàn, tốc độ cao ở đâu?
18/05/2024

Thuê mua proxy Telegram trọn gói, tốc độ cao, giá siêu hời
18/05/2024

Thuê mua proxy Viettel ở đâu uy tín, chất lượng và giá tốt? 
14/05/2024

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024