码迷,mamicode.com
首页 > 编程语言 > 详细

如何安装 JAVA 7 (JDK 7u75) 在 CentOS/RHEL 7/6/5 Fedora

时间:2015-03-07 06:11:55      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:

先下载JDK

For 64 Bit:-

# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz"

For 32 Bit:-

# cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-i586.tar.gz"

解压缩并移动到/opt下
# tar xzf jdk-7u75-linux-x64.tar.gz
# mv jdk1.7.0_75 /opt

设置为默认虚拟机
# cd /opt/jdk1.7.0_75/
# alternatives --install /usr/bin/java java /opt/jdk1.7.0_75/bin/java 2
# alternatives --config java

出现以下选项时选择4
There are 4 programs which provide ‘java‘. Selection Command ----------------------------------------------- * 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java + 2 /opt/jdk1.7.0_60/bin/java 3 /opt/jdk1.7.0_72/bin/java 4 /opt/jdk1.7.0_75/bin/java Enter to keep the current selection[+], or type selection number: 4 [Press Enter]

# alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_75/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_75/bin/javac 2
# alternatives --set jar /opt/jdk1.7.0_75/bin/jar
# alternatives --set javac /opt/jdk1.7.0_75/bin/javac 

现在可以试一下java的版本了,输出如下
# java -version

java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

设置一下环境变量
cat >> /etc/profile.d/java7.sh << EOF
export JAVA_HOME=/opt/jdk1.7.0_75
export JRE_HOME=/opt/jdk1.7.0_75/jre
export PATH=\$PATH:/opt/jdk1.7.0_75/bin:/opt/jdk1.7.0_75/jre/bin
EOF

 重开一下终端 env|grep HOME 就可以看见结果了

如何安装 JAVA 7 (JDK 7u75) 在 CentOS/RHEL 7/6/5 Fedora

标签:

原文地址:http://www.cnblogs.com/linbc/p/4319509.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!