CentOS 7 Redhat 7/6.4
java環境設置
yum install java-1.7.0-openjdk httpd unzip
1.下載 java 1.8.x
=====尚未測試=====
curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.rpm > jdk-8u60-linux-x64.rpm
-j -> junk cookies
-k -> ignore certificates
-L -> follow redirects
-H [arg] -> headers
=======已確定======
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.rpm
===================
oracle 的下載位置,可自行尋找需要的檔案網址替換
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
===================
下載檔案更名
mv jdk-8u60-linux-x64.rpm\?AuthParam\=1442376054_e8990f822638169aa21659ac512ee782 jdk-8u60-linux-x64.rpm
===================
安裝
yum -y install jdk-8u60-linux-x64.rpm
===================
環境設定
alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_60/bin/java 2
※若無此程式 yum -y install alternatives
===================
查詢目前已安裝的JAVA版本
java -version
===================
選擇環境預設的JAVA
/usr/sbin/alternatives --config java
[root@localhost ~]# vim /etc/profile
在檔案中新增以下段落,並在PATH變數中新增$JAVA_HOME/bin。
# JAVA
JAVA_HOME=/usr/java/jdk1.8.0_60/bin/java
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export JAVA_HOME CLASSPATH
vim /root/.bash_profile
JAVA_HOME=/usr/java/jdk1.8.0_60/bin/java
=====
$JAVA_HOME Check
echo $JAVA_HOME
printf $JAVA_HOME
env | grep JAVA_HOME
printenv | grep JAVA_HOME
==
設置完成
沒有留言:
張貼留言