Ubuntu14.04 安装openjdk7和openjdk8与切换

前端之家收集整理的这篇文章主要介绍了Ubuntu14.04 安装openjdk7和openjdk8与切换前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.安装

sudo add-apt-repository ppa:openjdk-r/ppa

sudo apt-get update

sudo apt-get install openjdk-7-jdk

sudo apt-get install openjdk-8-jdk

2.删除链接

切换路径到/etc/alternatives

查看软连接ll java*

lrwxrwxrwx1 root root 46 6月 3 17:41 java ->/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java*

lrwxrwxrwx1 root root 56 6月 3 17:41 java.1.gz ->/usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz

lrwxrwxrwx1 root root 43 6月 3 17:41 javac -> /usr/lib/jvm/java-7-openjdk-amd64/bin/javac*

lrwxrwxrwx1 root root 53 6月 3 17:41 javac.1.gz ->/usr/lib/jvm/java-7-openjdk-amd64/man/man1/javac.1.gz

lrwxrwxrwx1 root root 45 6月 3 17:41 javadoc ->/usr/lib/jvm/java-7-openjdk-amd64/bin/javadoc*

lrwxrwxrwx1 root root 55 6月 3 17:41 javadoc.1.gz ->/usr/lib/jvm/java-7-openjdk-amd64/man/man1/javadoc.1.gz

lrwxrwxrwx1 root root 43 6月 3 17:41 javah ->/usr/lib/jvm/java-7-openjdk-amd64/bin/javah*

lrwxrwxrwx1 root root 53 6月 3 17:41 javah.1.gz -> /usr/lib/jvm/java-7-openjdk-amd64/man/man1/javah.1.gz

lrwxrwxrwx1 root root 43 6月 3 17:41 javap ->/usr/lib/jvm/java-7-openjdk-amd64/bin/javap*

lrwxrwxrwx 1 root root 536月 3 17:41 javap.1.gz ->/usr/lib/jvm/java-7-openjdk-amd64/man/man1/javap.1.gz

参照此例删除所用的软链接

sudo update-alternatives --remove java/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

sudo update-alternatives --remove java/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

3.添加软链

sudo update-alternatives --install /usr/bin/jdk jdk/usr/lib/jvm/java-7-openjdk-amd64 1700

sudo update-alternatives --install /usr/bin/jdk jdk/usr/lib/jvm/java-8-openjdk-amd64 1800

4.配置环境变量

打开 ~/.bashrc

在最底部添加如下内容

alias jdk='sudoupdate-alternatives --config jdk'

exportJAVA_HOME=/usr/bin/jdk

exportCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

原文链接:https://www.f2er.com/ubuntu/352747.html

猜你在找的Ubuntu相关文章