引用自:https://www.linuxidc.com/Linux/2014-09/106218.htm
Ubuntu 14.04下安装 JDK8过程笔记,希望对大家有帮助。
检测系统是否安装jdk相关软件, 直接输入java 命令也可:
#如果提示:apt-get install <选定的软件包>,则系统默认没有安装。
[email protected]:~$ java -version
下载源码与解压:
[email protected]:~$wget
[email protected]:~$sudo mkdir /usr/lib/jvm
[email protected]:~$tar zvxf jdk-8u20-linux-x64.tar.gz
[email protected]:~$sudo mv jdk1.8.0_20/ /usr/lib/jvm/
设置JDK环境变量:
[email protected]:~$sudo vim ~/.profile
#set jdk env
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_20/
export JRE_HOME=/usr/lib/jvm/jdk1.8.0_20/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
#保存退出,输入以下命令使之立即生效。
[email protected]:~$source ~/.profile
验证JDK:
[email protected]:~$ java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
如果之前系统里面已经安装了openjdk,按照下面的步骤更新下即可:
[email protected]:~$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_20/bin/java 300
update-alternatives: using /usr/lib/jvm/jdk1.8.0_20/bin/java to provide /usr/bin/java (java) in auto mode
[email protected]:~$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_20/bin/javac 300
update-alternatives: using /usr/lib/jvm/jdk1.8.0_20/bin/javac to provide /usr/bin/javac (javac) in auto mode
[email protected]:~$ sudo update-alternatives --config java
[email protected]:~$ sudo update-alternatives --config javac
Ubuntu下安装JDK7(附Clojure下载) http://www.linuxidc.com/Linux/2012-10/71557.htm
Ubuntu 12.04下安装JDK1.7 http://www.linuxidc.com/Linux/2012-06/62239.htm
CentOS6.3安装JDK和环境配置 http://www.linuxidc.com/Linux/2012-09/70780.htm