1.到官网下载jdk,我选择的是jdk-8u111-linux-x64.tar.gz
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2.下载eclips,我选择的是Eclipse IDE for Java EE Developers
https://www.eclipse.org/downloads/eclipse-packages/
3.将jdk解压到 /opt/jvm/文件夹中
操作步骤:
sudo mkdir /opt/jvm
sudo tar zxvf jdk-8u111-linux-x64.tar.gz -C /opt/jvm
4.配置jdk的环境变量,打开 /etc/profile文件(sudo vim /etc/profile),在文件末尾添加下语句(注意不要等号前后不要留空格):
export JAVA_HOME=/opt/jvm/jdk1.8.0_77
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
然后保存后退出,
使其立即生效:
sudo-s
source /etc/profile
查看是否安装成功: