Open jinhucheung opened 8 years ago
分为下面5个步骤
网址: http://www.oracle.com/technetwork/articles/javase/index-jsp-138363.html 选择相应的 .gz包下载 (这里我选择了"jdk-8u92-linux-i586.tar.gz")
sudo mkdir /home/kumho/usr/lib/jvm
sudo tar -zxvf jdk-8u92-linux-i586.tar.gz -C /home/kumho/usr/lib/jvm
sudo vim ~/.bashrc 文件的末尾追加下面内容:
sudo vim ~/.bashrc
#set oracle jdk environment export JAVA_HOME=/home/kumho/usr/lib/jvm/jdk1.8.0_92 ##这里要注意目录要换成自己解压的jdk 目录 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
使环境变量马上生效source ~/.bashrc
source ~/.bashrc
sudo update-alternatives --install /usr/bin/java java /home/kumho/usr/lib/jvm/jdk1.8.0_92/bin/java 300 sudo update-alternatives --install /usr/bin/javac javac /home/kumho/usr/lib/jvm/jdk1.8.0_92/bin/javac 300 sudo update-alternatives --install /usr/bin/jar jar /home/kumho/usr/lib/jvm/jdk1.8.0_92/bin/jar 300 sudo update-alternatives --install /usr/bin/javah javah /home/kumho/usr/lib/jvm/jdk1.8.0_92/bin/javah 300 sudo update-alternatives --install /usr/bin/javap javap /home/kumho/usr/lib/jvm/jdk1.8.0_92/bin/javap 300
然后执行: sudo update-alternatives --config java 若是初次安装jdk,会有下面的提示 There is only one alternative in link group java (providing /usr/bin/java): /home/kumho/usr/lib/jvm/jdk1.8.0_92/bin/java 否则,选择合适的jdk
sudo update-alternatives --config java
直接下载jdk压缩包方式安装
分为下面5个步骤
1.官网下载JDK
网址: http://www.oracle.com/technetwork/articles/javase/index-jsp-138363.html 选择相应的 .gz包下载 (这里我选择了"jdk-8u92-linux-i586.tar.gz")
2.解压缩,放到指定目录(以jdk-8u92-linux-i586.tar.gz为例)
sudo mkdir /home/kumho/usr/lib/jvm
sudo tar -zxvf jdk-8u92-linux-i586.tar.gz -C /home/kumho/usr/lib/jvm
3. 修改环境变量
sudo vim ~/.bashrc
文件的末尾追加下面内容:使环境变量马上生效
source ~/.bashrc
4.设置系统默认jdk 版本
然后执行:
sudo update-alternatives --config java
若是初次安装jdk,会有下面的提示 There is only one alternative in link group java (providing /usr/bin/java): /home/kumho/usr/lib/jvm/jdk1.8.0_92/bin/java否则,选择合适的jdk
5.测试jdk