【openJDK】CentOS7.x 上 openJDK的安装与

2023-12-15  本文已影响0人  Bogon

openJDK的安装&环境变量

# yum -y install java

Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
Excluding 1 update due to versionlock (use "yum versionlock status" to show it)
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.392.b08-2.el7_9 will be installed
--> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.392.b08-2.el7_9 for package: 1:java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64
--> Processing Dependency: libjvm.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64
--> Processing Dependency: libjava.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64
--> Processing Dependency: libjvm.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64
--> Processing Dependency: libjava.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64
--> Running transaction check
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.392.b08-2.el7_9 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================================================
 Package                                                    Arch                                  Version                                                  Repository                              Size
========================================================================================================================================================================================================
Installing:
 java-1.8.0-openjdk                                         x86_64                                1:1.8.0.392.b08-2.el7_9                                  updates                                319 k
Installing for dependencies:
 java-1.8.0-openjdk-headless                                x86_64                                1:1.8.0.392.b08-2.el7_9                                  updates                                 33 M

Transaction Summary
========================================================================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 33 M
Installed size: 111 M
Downloading packages:
(1/2): java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64.rpm                                                                                                                       | 319 kB  00:00:00
(2/2): java-1.8.0-openjdk-headless-1.8.0.392.b08-2.el7_9.x86_64.rpm                                                                                                              |  33 MB  00:00:01
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                    20 MB/s |  33 MB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:java-1.8.0-openjdk-headless-1.8.0.392.b08-2.el7_9.x86_64                                                                                                                           1/2
  Installing : 1:java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64                                                                                                                                    2/2
  Verifying  : 1:java-1.8.0-openjdk-headless-1.8.0.392.b08-2.el7_9.x86_64                                                                                                                           1/2
  Verifying  : 1:java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64                                                                                                                                    2/2

Installed:
  java-1.8.0-openjdk.x86_64 1:1.8.0.392.b08-2.el7_9

Dependency Installed:
  java-1.8.0-openjdk-headless.x86_64 1:1.8.0.392.b08-2.el7_9

Complete!

# rpm -qa | grep java

java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64
javapackages-tools-3.4.1-11.el7.noarch
tzdata-java-2023c-1.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.392.b08-2.el7_9.x86_64
python-javapackages-3.4.1-11.el7.noarch
# yum info java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64

Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
Excluding 1 update due to versionlock (use "yum versionlock status" to show it)
Installed Packages
Name        : java-1.8.0-openjdk
Arch        : x86_64
Epoch       : 1
Version     : 1.8.0.392.b08
Release     : 2.el7_9
Size        : 646 k
Repo        : installed
From repo   : updates
Summary     : OpenJDK 8 Runtime Environment
URL         : http://openjdk.java.net/
License     : ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public Domain and W3C and zlib
Description : The OpenJDK 8 runtime environment.



# yum info java-1.8.0-openjdk-headless-1.8.0.392.b08-2.el7_9.x86_64

Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
Excluding 1 update due to versionlock (use "yum versionlock status" to show it)
Installed Packages
Name        : java-1.8.0-openjdk-headless
Arch        : x86_64
Epoch       : 1
Version     : 1.8.0.392.b08
Release     : 2.el7_9
Size        : 111 M
Repo        : installed
From repo   : updates
Summary     : OpenJDK 8 Headless Runtime Environment
URL         : http://openjdk.java.net/
License     : ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public Domain and W3C and zlib
Description : The OpenJDK 8 runtime environment without audio and video support.
# java -version
openjdk version "1.8.0_392"
OpenJDK Runtime Environment (build 1.8.0_392-b08)
OpenJDK 64-Bit Server VM (build 25.392-b08, mixed mode)
# which java
/usr/bin/java

# ll /bin/java
lrwxrwxrwx 1 root root 22 Dec 16 20:54 /bin/java -> /etc/alternatives/java

# ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Dec 16 20:54 /usr/bin/java -> /etc/alternatives/java


# rpm -qf /usr/bin/java
java-1.8.0-openjdk-headless-1.8.0.392.b08-2.el7_9.x86_64

# rpm -qf /bin/java
java-1.8.0-openjdk-headless-1.8.0.392.b08-2.el7_9.x86_64

# echo  $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
#  tail  /etc/profile

JAVA_HOME=/path/to/jdk
JRE_HOME=/path/to/jdk/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH

openJDK的卸载

# yum -y remove java*

Loaded plugins: fastestmirror, langpacks, versionlock
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.392.b08-2.el7_9 will be erased
---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.392.b08-2.el7_9 will be erased
---> Package javapackages-tools.noarch 0:3.4.1-11.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================================================
 Package                                                    Arch                                  Version                                                 Repository                               Size
========================================================================================================================================================================================================
Removing:
 java-1.8.0-openjdk                                         x86_64                                1:1.8.0.392.b08-2.el7_9                                 @updates                                646 k
 java-1.8.0-openjdk-headless                                x86_64                                1:1.8.0.392.b08-2.el7_9                                 @updates                                111 M
 javapackages-tools                                         noarch                                3.4.1-11.el7                                            @base                                   156 k

Transaction Summary
========================================================================================================================================================================================================
Remove  3 Packages

Installed size: 111 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64                                                                                                                                    1/3
  Erasing    : 1:java-1.8.0-openjdk-headless-1.8.0.392.b08-2.el7_9.x86_64                                                                                                                           2/3
  Erasing    : javapackages-tools-3.4.1-11.el7.noarch                                                                                                                                               3/3
  Verifying  : 1:java-1.8.0-openjdk-headless-1.8.0.392.b08-2.el7_9.x86_64                                                                                                                           1/3
  Verifying  : 1:java-1.8.0-openjdk-1.8.0.392.b08-2.el7_9.x86_64                                                                                                                                    2/3
  Verifying  : javapackages-tools-3.4.1-11.el7.noarch                                                                                                                                               3/3

Removed:
  java-1.8.0-openjdk.x86_64 1:1.8.0.392.b08-2.el7_9                 java-1.8.0-openjdk-headless.x86_64 1:1.8.0.392.b08-2.el7_9                 javapackages-tools.noarch 0:3.4.1-11.el7

Complete!


# which java
/usr/bin/which: no java in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)

# java -version
-bash: java: command not found
上一篇下一篇

猜你喜欢

热点阅读