标签:ubuntu12.04 jdk linux ubuntu14.04
检测系统是否安装jdk相关软件, 直接输入java 命令也可:
#如果提示:apt-get install <选定的软件包>,则系统默认没有安装。 junluobj@junluobj:~$ java -version
下载源码与解压:
junluobj@junluobj:~$wget junluobj@junluobj:~$sudo mkdir /usr/lib/jvm junluobj@junluobj:~$tar zvxf jdk-8u20-linux-x64.tar.gz junluobj@junluobj:~$sudo mv jdk1.8.0_20/ /usr/lib/jvm/
设置JDK环境变量:
junluobj@junluobj:~$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 #保存退出,输入以下命令使之立即生效。 junluobj@junluobj:~$source ~/.profile
验证JDK:
junluobj@junluobj:~$ 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,按照下面的步骤更新下即可:
junluobj@junluobj:~$ 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 junluobj@junluobj:~$ 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 junluobj@junluobj:~$ sudo update-alternatives --config java junluobj@junluobj:~$ sudo update-alternatives --config javac
本文出自 “每天进步一点点” 博客,请务必保留此出处http://lj119.blog.51cto.com/605062/1548462
标签:ubuntu12.04 jdk linux ubuntu14.04
原文地址:http://lj119.blog.51cto.com/605062/1548462