CentOS install JDK1.8 rpm version

Installation Notes

System environment: centos7   centos6.5
installation method: rpm installation 
software: jdk-8u25-linux-x64.rpm 
download address: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Check the original version of the system

[root@zck ~]# java -version
java version "1.7.0_"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
   
    
    
  • 1
  • 2
  • 3
  • 4

Further view JDK information:

[root@localhost ~]#  rpm -qa | grep java
javapackages-tools-3.4.1-6.el7_0.noarch
tzdata-java-2014i-1.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64
java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
python-javapackages-3.4.1-6.el7_0.noarch
   
    
    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Uninstall OpenJDK and perform the following operations:

[root@localhost ~]# rpm -e --nodeps tzdata-java-2014i-1.el7.noarch
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
   
    
    
  • 1
  • 2
  • 3

Install JDK

Upload the new jdk-8u25-linux-x64.rpm software to /usr/local/ and perform the following operations: 
[root@zck local]# rpm -ivh jdk-8u25-linux-x64.rpm

The JDK is installed in /usr/java by default.

Verify installation

Perform the following operations to check whether the information is normal:

[root@localhost ~]# java
[root@localhost ~]# javac
[root@localhost ~]# java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
   
    
    
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Configure environment variables

After installing jdk-7-linux-x64.rpm on my machine, javac and java -version operations can be performed normally without configuring environment variables, so I did not configure JDK environment variables. But for future uncomfortable needs, here is still a record of how to configure, the operation is as follows: 
modify the system environment variable file 
vi + /etc/profile

Append the following content to the file:

The location can be placed at the end of the profile file

JAVA_HOME=/usr/java/jdk1.8.0_25
JRE_HOME=/usr/java/jdk1.8.0_25/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
   
    
    
  • 1
  • 2
  • 3
  • 4
  • 5

Make changes take effect

[root@localhost ~]# source /etc/profile   //使修改立即生效
[root@localhost ~]#        echo $PATH   //查看PATH值
   
    
    
  • 1
  • 2

View system environment status

[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.8.0_25/bin:/usr/java/jdk1.8.0_25/jre/bin
   
    
    
  • 1
  • 2

Installation Notes

System environment: centos7   centos6.5
installation method: rpm installation 
software: jdk-8u25-linux-x64.rpm 
download address: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Check the original version of the system

[root@zck ~]# java -version
java version "1.7.0_"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
   
  
  
  • 1
  • 2
  • 3
  • 4

Further view JDK information:

[root@localhost ~]#  rpm -qa | grep java
javapackages-tools-3.4.1-6.el7_0.noarch
tzdata-java-2014i-1.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64
java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
python-javapackages-3.4.1-6.el7_0.noarch
   
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Uninstall OpenJDK and perform the following operations:

[root@localhost ~]# rpm -e --nodeps tzdata-java-2014i-1.el7.noarch
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.71-2.5.3.1.el7_0.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.71-2.5.3.1.el7_0.x86_64
   
  
  
  • 1
  • 2
  • 3

Install JDK

Upload the new jdk-8u25-linux-x64.rpm software to /usr/local/ and perform the following operations: 
[root@zck local]# rpm -ivh jdk-8u25-linux-x64.rpm

The JDK is installed in /usr/java by default.

Verify installation

Perform the following operations to check whether the information is normal:

[root@localhost ~]# java
[root@localhost ~]# javac
[root@localhost ~]# java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
   
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Configure environment variables

After installing jdk-7-linux-x64.rpm on my machine, javac and java -version operations can be performed normally without configuring environment variables, so I did not configure JDK environment variables. But for future uncomfortable needs, here is still a record of how to configure, the operation is as follows: 
modify the system environment variable file 
vi + /etc/profile

Append the following content to the file:

The location can be placed at the end of the profile file

JAVA_HOME=/usr/java/jdk1.8.0_25
JRE_HOME=/usr/java/jdk1.8.0_25/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
   
  
  
  • 1
  • 2
  • 3
  • 4
  • 5

Make changes take effect

[root@localhost ~]# source /etc/profile   //使修改立即生效
[root@localhost ~]#        echo $PATH   //查看PATH值
   
  
  
  • 1
  • 2

View system environment status

[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.8.0_25/bin:/usr/java/jdk1.8.0_25/jre/bin
   
  
  
  • 1
  • 2

Guess you like

Origin blog.csdn.net/fclwd/article/details/78195080