0%

linux安装jdk

linux安装jdk

http://www.linuxidc.com/Linux/2016-07/133482.htm 安装jdk和eclipse

准备jdk

https://www.oracle.com/java/technologies/javase-jdk8-downloads.html oracle的jdk 8的下载页
访问oracle的jdk 8的下载页, 登录java帐号, 下载jdk-8u121-linux-x64.tar.gz

安装jdk

jdk放置/opt/jvm, 并解压

1
2
3
4
5
6
dassein@pad:~$ su root
Password:
root@pad:/home/dassein# mv /home/dassein/Downloads/jdk-8u121-linux-x64.tar.gz /opt/jvm/
root@pad:/home/dassein# sudo tar zxvf /opt/jvm/jdk-8u121-linux-x64.tar.gz -C /opt/jvm
jdk1.8.0_121/
jdk1.8.0_121/THIRDPARTYLICENSEREADME-JAVAFX.txt

配置jdk的环境变量

打开 /etc/profile 即(sudo vim /etc/profile), 在文件末尾添加语句

1
2
3
4
5
6
7
export JAVA_HOME=/opt/jvm/jdk1.8.0_121

export JRE_HOME=${JAVA_HOME}/jre

export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib

export PATH=${JAVA_HOME}/bin:$PATH

保存后退出

使其立即生效:sudo source /etc/profile

查看是否安装成功:java -version 出现 java version "1.8.0_121"

说明jdk安装成功

1
2
3
4
5
6
root@pad:/home/dassein# sudo vim /etc/profile
root@pad:/home/dassein# source /etc/profile
dassein@pad:~$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)