标签:
首先到官方找到下载地址:
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
使用wget命令下载jdk1.7
# 通常需要下载jdk时,直接用wget命令是不行的。解决办法如下:
# 只需要在wget的时候加上一个特殊的cookie就可以搞定,下载最新版jdk-7u21的完整命令:
wget --no-cookie --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz?AuthParam=1461458726_3c8fc7f6eaa41b7c74384bfbbc4fff24
# 而如果出现Unable to establish SSL connection的话,在wget后面加上–no-check-certificate即可,命令如下:
wget --no-cookie --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz?AuthParam=1461458726_3c8fc7f6eaa41b7c74384bfbbc4fff24
设置jdk环境变量 这里采用全局设置方法,就是修改etc/profile,它是是所有用户的共用的环境变量
sudo gedit /etc/profile
打开之后在末尾添加
export JAVA_HOME=/usr/local/java/jdk1.7.0_45
export JRE_HOME=/usr/local/java/jdk1.7.0_45/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin: $PATH
然后保存
source /etc/profile
标签: