How to install JDK and set environment variables in Linux (this article is enough)

How to install JDK and set environment variables in Linux (this article is enough)

1. Check the number of Linux bits

Check whether Linux is 32-bit or 64-bit, which affects the version of JDK you need to download

System Bits JDK bit number
x86 (32-bit) 32-bit
x86_64 (64-bit)

32-bit

64-bit

Enter the command in Linux:

uname -a

If it is a 64-bit machine, it will output x86_64

2. Download JDK

Download address: https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html

Corresponding to step 1, download the 64-bit version of linx

3. Install JDK

Upload the downloaded jdk to linux and unzip the compressed file

tar -zxvf jdk-11.0.6_linux-x64_bin.tar.gz

4. Set environment variables

Modify the /etc/profile file

vim /etc/profile, add the following content:

export JAVA_HOME=/usr/local/jdk/jdk-11.0.6 #Change to the installation path of jdkexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH

source /etc/profile to make the environment variables effective

5. Test results

Enter the command in Linux:

[root@localhost local]# java -version
java version "11.0.6" 2020-01-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.6+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)

Seeing the above results, it means that jdk is installed successfully

Summarize

The above is the tutorial on how to install JDK in Linux and set environment variables introduced by the editor. I hope it will be helpful to everyone!

You may also be interested in:
  • Linux jdk installation and environment variable configuration tutorial (jdk-8u144-linux-x64.tar.gz)
  • 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
  • Install JDK1.8 in Linux environment

<<:  MySQL calculates the number of days, months, and years between two dates

>>:  Detailed tutorial on downloading mysql on Windows 10

Recommend

jQuery implements employee management registration page

This article example shares the specific code of ...

Methods and steps for Etcd distributed deployment based on Docker

1. Environmental Preparation 1.1 Basic Environmen...

Vue implements Dialog encapsulation

Table of contents Vue2 Writing Vue3 plugin versio...

js to achieve simulated shopping mall case

Friends who are learning HTML, CSS and JS front-e...

How to configure environment variables in Linux environment

JDK download address: http://www.oracle.com/techn...

Comparison of mydumper and mysqldump in mysql

If you only want to back up a few tables or a sin...

CSS to achieve zoom in and out close button (example code)

This effect is most common on our browser page. L...

MySQL uses variables to implement various sorting

Core code -- Below I will demonstrate the impleme...

MySQL infobright installation steps

Table of contents 1. Use the "rpm -ivh insta...

Detailed Analysis of or, in, union and Index Optimization in MySQL

This article originated from the homework assignm...

Vue+echarts realizes stacked bar chart

This article shares the specific code of Vue+echa...

How to use Linux whatis command

01. Command Overview The whatis command searches ...

Mysql implements null value first/last method example

Preface We already know that MySQL uses the SQL S...

Steps to install RocketMQ instance on Linux

1. Install JDK 1.1 Check whether the current virt...