Linux安装jdk 8和环境变量配置
1、下载jdk
地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2、将刚刚下载的文件解压到/usr/lib/jvm目录之下,假设没有该目录。能够新建目录
cp -r /home/xx/下载/jdk1.8.0_25 /usr/lib/jvm
3、配置环境变量
敲入命令:
gedit ~/.bashrc
在最后加入上:
1
2
3
4
|
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_25
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
|
source |
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_25 /bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_25 /bin/javac 300
5、測试
打开一个终端输入依稀命令
java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) Server VM (build 25.25-b02, mixed mode)
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) Server VM (build 25.25-b02, mixed mode)
它代表了成功的测试。