CentOS6.5卸载openJDK和安装Sun JDK

方今作业须要,新安装了CentOS6.5系统,在陈设tomcat的时候,总是报错找不到jdk中的java。商讨了半天,发现应该是openJDK的标题。一般CentOS6.5都会默许安装openJDK,所以啊,又温习了弹指间什么在Linux系统安装Sun
JDK,分享一下~

用到的工具:CentOS6.5、jdk-8u181-linux-x64.rpm、WinSCP(用于上传文件到服务器或虚拟机)

 

Step1. 询问已设置openJDK列表:

# 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.x86_64

java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64

 

Step2.
卸载:

# rpm -e –nodeps
tzdata-java-2013g-1.el6.noarch

# rpm -e –nodeps
java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.x86_64

# rpm -e –nodeps
java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64

 

 

 

Step3.
再度运行,结果为空:

# rpm -qa | grep
java

 

Step4.
使用上传文件工具WinSCP将jdklinux版安装包上传播虚拟机上。那里上传播/root/uploadFile

澳门金沙国际 1

# cd
/root/uploadFile

查阅是不是上传成功:

# ls

jdk-8u181-linux-x64.rpm

 

Step5.
安装:

# rpm -ivh
jdk-8u181-linux-x64.rpm

warning:
jdk-8u181-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID
ec551f03: NOKEY

Preparing…               
###########################################
[100%]

  
1:jdk1.8                
###########################################
[100%]

Unpacking JAR
files…

       
tools.jar…

       
plugin.jar…

       
javaws.jar…

       
deploy.jar…

       
rt.jar…

       
jsse.jar…

       
charsets.jar…

       
localedata.jar…

 

Step6.
验证是或不是安装成功:

# java
-version

java version
“1.8.0_181”

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

Java HotSpot(TM)
64-Bit Server VM (build 25.181-b13, mixed mode)

 

Step7.
确认安装路径:

貌似设置路径为/usr/java

# ls
/usr/java

default 
jdk1.8.0_181-amd64  latest

 

要么应用以下格局:

# which
java

/usr/bin/java

# ls -lrt
/usr/bin/java

lrwxrwxrwx. 1 root
root 22 Aug 28 21:05 /usr/bin/java -> /etc/alternatives/java

# ls -lrt
/etc/alternatives/java

lrwxrwxrwx. 1 root
root 41 Aug 28 21:05 /etc/alternatives/java -> /usr/java/jdk1.8.0_181-amd64/jre/bin/java

说到底加红的字段/usr/java/jdk1.8.0_181-amd64便是JDK的装置路径。

 

Step8. 确认后接纳vim /etc/profile打开文件,配置环境变量:

# vim
/etc/profile

尾部添加:

export
JAVA_HOME=/usr/java/jdk1.8.0_181-amd64

export
JRE_HOME=$JAVA_HOME/jre

export
CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib

export
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

 

Step9. 使配置生效:

# source
/etc/profile

 

Step10.
验证是还是不是见效:

# echo
$JAVA_HOME

/usr/java/jdk1.8.0_181-amd64

# echo
$CLASSPATH

:/usr/java/jdk1.8.0_181-amd64/lib:/usr/java/jdk1.8.0_181-amd64/jre/lib

 

到那里就finish了啊~而且我tomcat的谬误也解决了~

 

CentOS下JDK安装

CentOS下JDK安装

设置形式:rpm安装
软件:jdk-7-linux-x64.rpm
下载地址:

检查系统原版本

[[email protected]
~]# java -version

java version “1.6.0_24”

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)

越发查看JDK新闻: 

[[email protected]
~]# rpm -qa | grep java

CentOS6.5卸载openJDK和安装Sun JDK。tzdata-java-2012c-1.el6.noarch

java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64

卸载OpenJDK,执行以下操作: 

[[email protected]
~]# rpm -e –nodeps tzdata-java-2012c-1.el6.noarch

[[email protected]
~]# rpm -e –nodeps java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64

安装JDK

上传新的jdk-7-linux-x64.rpm软件到/usr/local/执行以下操作: 

[[email protected]
local]# rpm -ivh jdk-7-linux-x64.rpm

JDK默认安装在/usr/java中。 

表明安装

实践以下操作,查看新闻是或不是正规: 

[[email protected]
bin]# java

[[email protected]
bin]# javac

[[email protected]
bin]# java -version

java version “1.7.0”

Java(TM) SE Runtime Environment (build 1.7.0-b147)

Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

恭贺,安装成功! 

布局环境变量

本身的机器安装完jdk-7-linux-x64.rpm后不要配置环境变量也足以健康履行javac、java
–version操作,因而我未曾进展JDK环境变量的布局。可是为了未来的不适之需,那里依然记录一下怎么开展配置,操作如下:

修改系统环境变量文件 

vi + /etc/profile

向文件之中追加以下内容: 

JAVA_HOME=/usr/java/jdk1.7.0

JRE_HOME=/usr/java/jdk1.7.0/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

使修改生效

 [[email protected]
local]# source /etc/profile //使修改立时生效

[[email protected]
local]# echo $PATH //查看PATH值

查看系统环境情况 

[[email protected]
~]# echo $PATH

/usr/local/cmake/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/java/jdk1.7.0/bin:/usr/java/jdk1.7.0/jre/bin:/root/bin

Ubuntu下安装JDK7(附Clojure下载)

Ubuntu 12.04下安装JDK1.7

CentOS6.3安装JDK和条件安顿

CentOS下JDK安装 安装格局:rpm安装
软件:jdk-7-linux-x64.rpm
下载地址:…

http://blog.csdn.net/jeffleo/article/details/53559712?utm\_source=itdadao&utm\_medium=referral

CentOS 6.8
安装JDK1.7

**CentOS

检查Linux系统是不是已设置jdk

6.8 安装JDK1.7**

[root@linux1 ~]# rpm -qa | grep java

检查Linux系统是还是不是已安装jdk

tzdata-java-2016c-1.el6.noarch

[root@linux1 ~]# rpm -qa | grep java

java-1.6.0-openjdk-1.6.0.38-1.13.10.4.el6.x86_64

tzdata-java-2016c-1.el6.noarch

java-1.7.0-openjdk-1.7.0.99-2.6.5.1.el6.x86_64

java-1.6.0-openjdk-1.6.0.38-1.13.10.4.el6.x86_64

卸载系统自带的java

java-1.7.0-openjdk-1.7.0.99-2.6.5.1.el6.x86_64

[root@linux3 ~]# rpm -qa | grep java | xargs rpm -e –nodeps

卸载系统自带的java

翻看卸载结果

[root@linux3 ~]# rpm -qa | grep java | xargs rpm -e –nodeps

[root@linux3 ~]# java -version

查阅卸载结果

bash: /usr/bin/java: No such file or directory

[root@linux3 ~]# java -version

卸载成功

bash: /usr/bin/java: No such file or directory

下载jdk

卸载成功

下载jdk

jdk-7u79-linux-x64.rpm

http://www.Oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

jdk-7u79-linux-x64.tar.gz

jdk-7u79-linux-x64.rpm

先是种方法:rpm包安装

jdk-7u79-linux-x64.tar.gz

rpm包导入用户root目录下

先是种方式:rpm包安装

[root@linux2 ~]# ls

rpm包导入用户root目录下

anaconda-ks.cfg  id_dsa.pub  install.log  install.log.syslog 

[root@linux2 ~]# ls

jdk-7u79-linux-x64.rpm

anaconda-ks.cfg id_dsa.pub install.log install.log.syslog

授予权力

jdk-7u79-linux-x64.rpm

[root@linux2 ~]# chmod 755 jdk-7u79-linux-x64.rpm

赋予权力

安装

[root@linux2 ~]# chmod 755 jdk-7u79-linux-x64.rpm

[root@linux2 ~]# rpm -ivh jdk-7u79-linux-x64.rpm

安装

Preparing…               
###########################################
[100%]

[root@linux2 ~]# rpm -ivh jdk-7u79-linux-x64.rpm

1:jdk                   
###########################################
[100%]

Preparing…
###########################################
[100%]

Unpacking JAR files…

1:jdk
###########################################
[100%]

rt.jar…

Unpacking JAR files…

jsse.jar…

rt.jar…

charsets.jar…

jsse.jar…

tools.jar…

charsets.jar…

localedata.jar…

tools.jar…

jfxrt.jar…

localedata.jar…

设置到位

jfxrt.jar…

第三种艺术:二进制包安装

安装已毕

建立JAVA_HOME目录

其次种艺术:二进制包安装

[root@linux3 ~]# mkdir /usr/java

建立JAVA_HOME目录

将二进制包放在 /usr/java/ 下并解压

[root@linux3 ~]# mkdir /usr/java

[root@linux3 ~]# mv jdk-7u79-linux-x64.tar.gz /usr/java

将二进制包放在 /usr/java/ 下并解压

[root@linux3 ~]# cd /usr/java

[root@linux3 澳门金沙国际 ,~]# mv jdk-7u79-linux-x64.tar.gz /usr/java

[root@linux3 java]# tar xvf jdk-7u79-linux-x64.tar.gz

[root@linux3 ~]# cd /usr/java

翻看结果

[root@linux3 java]# tar xvf jdk-7u79-linux-x64.tar.gz

[root@linux3 java]# ls

查看结果

jdk1.7.0_79  jdk-7u79-linux-x64.tar.gz

[root@linux3 java]# ls

为了节省空间,可以将二进制包删去

jdk1.7.0_79 jdk-7u79-linux-x64.tar.gz

[root@linux3 java]# rm -rf jdk-7u79-linux-x64.tar.gz

为了节省空间,可以将二进制包删去

布署全局java环境变量

[root@linux3 java]# rm -rf jdk-7u79-linux-x64.tar.gz

[root@linux3 java]# vi /etc/profile

安顿全局java环境变量

终极面添加

[root@linux3 java]# vi /etc/profile

export JAVA_HOME=/usr/java/jdk1.7.0_79

说到底面添加

export JRE_HOME=$JAVA_HOME/jre

export JAVA_HOME=/usr/java/jdk1.7.0_79

export PATH=$PATH:$JAVA_HOME/bin

export JRE_HOME=$JAVA_HOME/jre

export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

export PATH=$PATH:$JAVA_HOME/bin

封存退出

export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

使profile配置生效

封存退出

[root@linux3 java]# source /etc/profile

使profile配置生效

配备用户java环境变量

[root@linux3 java]# source /etc/profile

[root@linux3 java]# vi ~/.bashrc

布置用户java环境变量

export JAVA_HOME=/usr/java/jdk1.7.0_79

[root@linux3 java]# vi ~/.bashrc

export JRE_HOME=$JAVA_HOME/jre

export JAVA_HOME=/usr/java/jdk1.7.0_79

export PATH=$PATH:$JAVA_HOME/bin

export JRE_HOME=$JAVA_HOME/jre

export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

export PATH=$PATH:$JAVA_HOME/bin

使bashrc配置生效

export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

[root@linux3 java]# source ~/.bashrc

使bashrc配置生效

检查一下环境变量

[root@linux3 java]# source ~/.bashrc

[root@linux3 java]# echo $JAVA_HOME

检查一下环境变量

/usr/java/jdk1.7.0_79

[root@linux3 java]# echo $JAVA_HOME

[root@linux3 java]# echo $CLASSPATH

/usr/java/jdk1.7.0_79

./:/usr/java/jdk1.7.0_79/lib:/usr/java/jdk1.7.0_79/jre/lib

[root@linux3 java]# echo $CLASSPATH

[root@linux3 java]# echo $PATH

./:/usr/java/jdk1.7.0_79/lib:/usr/java/jdk1.7.0_79/jre/lib

/usr/local/cmake-2.8.10.2/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/local/cmake-2.8.10.2/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.7.0_79/bin:/usr/java/jdk1.7.0_79/bin

[root@linux3 java]# echo $PATH

设置完结

/usr/local/cmake-2.8.10.2/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/local/cmake-2.8.10.2/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.7.0_79/bin:/usr/java/jdk1.7.0_79/bin

末尾检测一下业已安装的jdk

安装已毕

[root@linux3 java]# java -version

末段检测一下曾经安装的jdk

java version “1.7.0_79”

[root@linux3 java]# java -version

Java(TM) SE Runtime Environment (build 1.7.0_79-b15)

java version “1.7.0_79”

Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

Java(TM) SE Runtime Environment (build 1.7.0_79-b15)

或者输入 javac

Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

CentOS7.2安装JDK1.7 http://www.linuxidc.com/Linux/2016-11/137398.htm

仍旧输入 javac

CentOS 搭建JDK环境 
http://www.linuxidc.com/Linux/2015-06/118879.htm 

Ubuntu
14.04安装JDK1.8.0_25与布置环境变量 
http://www.linuxidc.com/Linux/2015-01/112030.htm 

Ubuntu 14.04 LTS安装Oracle JDK 1.8 
http://www.linuxidc.com/Linux/2014-11/109216.htm 

CentOS6.3安装JDK和环境布置
http://www.linuxidc.com/Linux/2012-09/70780.htm 

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-12/138912.htm

澳门金沙国际 2

相关文章