Install JDK1.8 in Linux environment

Install JDK1.8 in Linux environment

This article mainly introduces how to install JDK in Linux environment. Because Java is often indispensable in Linux environment, the author will share with you the process of jdk1.8.

1. Installation Environment

Operating system: Red Hat Enterprise Linux 6 64-bit (version 6.6)

JDK version: 1.8

Tools: Xshell5, Xftp5

Note: This article uses the Xshell5 tool to remotely connect to Linux for operation. It would be more convenient if you operate directly in the Linux visual interface. The principle is the same.

2. Installation steps

Step 1: Download the installation package

Download jdk1.8 in Linux environment, please go to (official website) to download the jdk installation file;

Since my Linux is 64-bit, I download jdk-8u131-linux-x64.tar.gz.

As shown in the following figure:

If Linux itself is connected to the Internet, we can directly download the JDK installation package through the wget command, as shown in the figure:

If there is no external network environment, still install the above method to download the installation package, and then upload it to the server

Step 2: Unzip the installation package

Upload the downloaded JDK installation package to the server and decompress it

Decompression command to decompress

1 $ cd /home/xxxxxxxx
2 $ tar -zxvf jdk-8u131-linux-x64.tar.gz 

After the decompression is complete, you can see a directory named [jdk1.8.0_131] in the current directory, which contains relevant files

We need to move all the data in the unzipped [jdk1.8.0_131] to the folder we need to install. We plan to install jdk in usr/java. We create a new java folder in the usr directory.

mkdir /usr/java

Copy the data in [jdk1.8.0_131] to the java directory

mv /home/xxxxxxxx/jdk1.8.0_131 /usr/java 

Step 3: Modify environment variables

At this point, we finally need to modify the environment variables through the command

vim /etc/profile

Use the vim editor to edit the profile file and add the following content to the end of the file (press "i" to enter the editing):

export JAVA_HOME=/usr/java/jdk1.8.0_131
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}

As shown in the figure:

Then, save and exit (press: wq!)

After saving, we also need to make this environment variable configuration information take effect, otherwise we can only restart the computer to take effect.

Use the command source /etc/profile to make the profile file take effect immediately, as shown in the figure

Step 4: Test whether the installation is successful

  • ①. Use the javac command, and there will be no command not found error
  • ②、Use java -version, the version displayed is java version "1.8.0_131"
  • ③、echo $PATH to see if the environment variables you just set are configured correctly

As shown in the figure:

At this point, the installation is complete

This concludes this article about installing JDK1.8 in Linux environment. I hope it will be helpful for everyone’s study, and I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Linux jdk installation and environment variable configuration tutorial (jdk-8u144-linux-x64.tar.gz)
  • How to install JDK and set environment variables in Linux (this article is enough)
  • How to configure jdk environment under Linux
  • Detailed tutorial on installing JDK1.8 on Linux
  • Tutorial on installing jdk1.8 and configuring environment variables under Linux

<<:  CSS3 flexible box flex to achieve three-column layout

>>:  In-depth understanding of javascript prototype and prototype chain

Recommend

How to quickly paginate MySQL data volumes of tens of millions

Preface In backend development, in order to preve...

DOM operation table example (DOM creates table)

1. Create a table using HTML tags: Copy code The ...

Vue practice of preventing multiple clicks

Generally, click events will be divided into diff...

Docker data volume container creation and usage analysis

A data volume container is a container specifical...

How to use crontab to add scheduled tasks in Linux

Preface The Linux system is controlled by the sys...

Html tips to make your code semantic

Html semantics seems to be a commonplace issue. G...

Detailed explanation of how to monitor MySQL statements

Quick Reading Why do we need to monitor SQL state...

Vue uses element-ui to implement menu navigation

This article shares the specific code of Vue usin...

Explain TypeScript mapped types and better literal type inference

Table of contents Overview Using mapped types to ...

Use scripts to package and upload Docker images with one click

The author has been working on a micro-frontend p...