Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux server-install jdk

Shulou Source: shulou.com Published: 2022-06-02 05:57:12 10月20日 Update

Install jdk

Jdk is a necessary tool for running or developing java. A lot of software depends on jdk, so you must learn to install jdk.

1. Check the jdk status of the current system

[root@localhost wj] # rpm-qa | grep java

Tzdata-java-2013g-1.el6.noarch

Java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.i686 / / you can see that jdk is installed on the current system, but the version is too old

Java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.i686

2. Delete the system jdk package

[root@localhost wj] # yum remove-y java-1.6.0

[root@localhost wj] # yum remove-y java-1.7.0

[root@localhost wj] # rpm-qa | grep java / / check whether it has been deleted

Tzdata-java-2013g-1.el6.noarch

3. Go to the official website to download the latest jdk package, http://www.oracle.com/technetwork/java/javase/downloads/index.html, and pay attention to 64-bit or 32-bit when downloading

4. Copy the downloaded package to "/ usr/local/src/" and decompress it.

[root@localhost src] # cp / media/sf_data/jdk-10.0.2_linux-x64_bin.tar / usr/local/src/jdk.tar

[root@localhost src] # tar-xvf jdk.tar

5. Configure the jdk environment variable, open "/ etc/profile", and append the following at the end

[root@localhost src] # gedit / etc/profile

# java environment

Export JAVAHOME=/usr/local/src/jdk-10.0.2 / / this path is the path of jdk decompression.

Export CLASSPATH=.:$ {JAVAHOME} / jre/lib/rt.jar:$ {JAVAHOME} / lib/dt.jar:$ {JAVAHOME} / lib/tools.jar

Export PATH=$PATH:$ {JAVAHOME} / bin

6. Refresh profile

[root@localhost src] # source / etc/profile

7. Test jdk and enter the command "Java-version" in the terminal.

[root@localhost src] # java-version

Java version "1.8.0,181"

Java (TM) SE Runtime Environment (build 1.8.0_181-b13)

Java HotSpot (TM) Client VM (build 25.181-b13, mixed mode)

[root@localhost src] #

Tags: System path variable command that is tool situation time version environment terminal software development test input run configuration server service Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MariaDB Huawei Linux Shulou Tech Info