search
HomeComputer TutorialsComputer KnowledgeCentOS installation JDK tutorial

CentOS installation JDK tutorial

Feb 29, 2024 pm 01:46 PM
javacentosjdkMemory usagejava compiler

CentOS is a Linux distribution built on the Red Hat Enterprise Linux source code and is popular for its stability and reliability. Widely used in server and enterprise environments, CentOS offers powerful features and advanced security, making it one of the preferred operating systems for many developers and system administrators.

CentOS installation JDK tutorial

JDK is the abbreviation of Java Development Kit. It is the core of the Java programming language and includes key tools such as Java Runtime Environment (JRE), Java Compiler (javac), and Java Virtual Machine (JVM). For Java development on CentOS systems, installing JDK is an indispensable first step.

Installing JDK on CentOS is very simple, the following are the detailed steps:

1. Make sure your CentOS system is connected to the Internet and has root permissions.

2. Open a terminal and enter the following command to update system packages: sudo yum update

3. Before installing JDK, you need to install Java Runtime Environment (JRE). Enter the following command to install JRE: sudo yum install java-1.8.0-openjdk

4. After installing JRE, you can continue to install JDK and enter the following command to install JDK: sudo yum install java-1.8.0-openjdk-devel

5. After the installation is complete, you can use the following command to verify whether the JDK is successfully installed: java -version

In order to ensure that Java programs can run normally in any location, Java environment variables need to be configured. You can edit the /etc/profile file and add specific content at the end to achieve this.

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk

export PATH=$PATH:$JAVA_HOME/bin

Save and exit the file, then run the following command to make the configuration take effect:

source /etc/profile

In order to verify whether the JDK is correctly installed and configured, you can write a simple Java program and run it to create a HelloWorld.java file with the following content:

“`java

public class HelloWorld {

public static void main(String[] args) {

System.out.println(“Hello, World!”);

}

}

“`

After saving the file, use the following commands to compile and run the program:

javac HelloWorld.java

java HelloWorld

If you see the output "Hello, World!", it means that the JDK has been successfully installed and configured.

Through the above steps, you have successfully installed JDK on CentOS and configured environment variables. You can start Java development. JDK is the foundation of Java development and one of the necessary tools for every Java developer.

In the Linux system, you can use the command "top" to view the real-time performance data of the system, including CPU usage, memory usage, etc. Through the "top" command, you can monitor the running status of the system in time and discover in time and solve the problem.

The above is the detailed content of CentOS installation JDK tutorial. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:每日运维. If there is any infringement, please contact admin@php.cn delete
Is Outriders Crossplay Not Working? Why and How to Fix It? - MiniToolIs Outriders Crossplay Not Working? Why and How to Fix It? - MiniToolMay 10, 2025 am 12:03 AM

What is Outriders Crossplay? How to enable it? Is Outriders Crossplay not working? If you are hit by this annoying issue, how to get rid of the trouble? Take it easy and go to see this post from php.cn to know much information about the game.

How to Use ChatGPT on Android and iOS Devices? See the Guide! - MiniToolHow to Use ChatGPT on Android and iOS Devices? See the Guide! - MiniToolMay 10, 2025 am 12:02 AM

Is ChatGPT available on Android & iOS? How to use ChatGPT on mobile devices? If you wonder about questions to these queries, this post could help you. Here, php.cn offers a detailed guide to you to help you easily run ChatGPT on your iPhone and A

Get ms-resource:AppName/Text Issue in Windows 11/10? Fix It!Get ms-resource:AppName/Text Issue in Windows 11/10? Fix It!May 10, 2025 am 12:01 AM

What is ms-resource:AppName/Text in Windows 11/10? How to remove this prominent problem from your PC? Take it easy if you suffer from this issue, go to find out what you should do to address it in this post on the php.cn website.

Notion Download, Install, Update, and Reset on Windows/Mac - MiniToolNotion Download, Install, Update, and Reset on Windows/Mac - MiniToolMay 09, 2025 am 12:54 AM

The Notion is a popular productivity program used for note-taking and organizing your thoughts, projects, and information. If you have not tried it yet, you should give it a chance. This article about Notion download on php.cn Website will give you a

How to Fix SSL Certificate Error in FireFox/Chrome? - MiniToolHow to Fix SSL Certificate Error in FireFox/Chrome? - MiniToolMay 09, 2025 am 12:53 AM

SSL certificate error is a common error when using a browser. Why does it occur and how to fix it on Windows 10/11? Follow the suggestions in this post on php.cn Website, you can resolve it easily.

Fix Windows Defender Exclusions Not Working Windows 11/10 - MiniToolFix Windows Defender Exclusions Not Working Windows 11/10 - MiniToolMay 09, 2025 am 12:52 AM

Do you know what is the Windows Defender exclusions? Do you have any idea how to exclude a folder from Windows Defender Windows 11/10? What if Windows Defender exclusions not working? Read this post given by php.cn to get the answers.

Windows 10 22H2 First Preview Build: Windows 10 Build 19045.1865 - MiniToolWindows 10 22H2 First Preview Build: Windows 10 Build 19045.1865 - MiniToolMay 09, 2025 am 12:51 AM

Microsoft has just released Windows 10 build 19045.1865 to the Release Preview Channel. This is the first preview build for Windows 10 22H2. php.cn Software will show you some related information about this build in this post.

Steam Not Downloading at Full Speed? A Quick Guide Here!Steam Not Downloading at Full Speed? A Quick Guide Here!May 09, 2025 am 12:50 AM

Steam gains large popularity among game players all around the world for its rich variety of games. However, have you ever encountered Steam not downloading at full speed? Why is Steam not downloading at full speed? If your Steam download speed drops

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use