概述
首先保证openjdk正常安装:
sudo apt-get -y install openjdk-7-jdk 一条命令搞定
jdk1.6安装:
下载,执行安装 ./jdk-6u33-linux-x64.bin
配置环境变量:
sudo gedit /etc/environment
#PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
#java
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/java/jdk1.6.0_32/bin:/usr/lib/jvm/java/jdk1.6.0_32/jre/bin"
JAVA_HOME=/usr/lib/jvm/java/jdk1.6.0_32
JRE_HOME=/usr/lib/jvm/java/jdk1.6.0_32/jre
CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib
#!/bin/bash
sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/java/jdk1.6.0_32/bin/javah 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java/jdk1.6.0_32/bin/javac 300
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java/jdk1.6.0_32/bin/java 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/java/jdk1.6.0_32/bin/jar 300
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/java/jdk1.6.0_32/bin/javap 300
sudo update-alternatives --install /usr/bin/jps jps /usr/lib/jvm/java/jdk1.6.0_32/bin/jps 300
sudo update-alternatives --install /usr/bin/jconsole jconsole /usr/lib/jvm/java/jdk1.6.0_32/bin/jconsole 300
sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/java/jdk1.6.0_32/bin/javadoc 300
sudo update-alternatives --install /usr/bin/appletviewer appletviewer /usr/lib/jvm/java/jdk1.6.0_32/bin/appletviewer 300
sudo update-alternatives --install /usr/bin/apt apt /usr/lib/jvm/java/jdk1.6.0_32/bin/apt 300
sudo update-alternatives --install /usr/bin/extcheck extcheck /usr/lib/jvm/java/jdk1.6.0_32/bin/extcheck 300
sudo update-alternatives --install /usr/bin/idlj idlj /usr/lib/jvm/java/jdk1.6.0_32/bin/idlj 300
sudo update-alternatives --install /usr/bin/jarsigner jarsigner /usr/lib/jvm/java/jdk1.6.0_32/bin/jarsigner 300
sudo update-alternatives --install /usr/bin/jdb jdb /usr/lib/jvm/java/jdk1.6.0_32/bin/jdb 300
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/java/jdk1.6.0_32/bin/javaws 300
sudo update-alternatives --install /usr/bin/jhat jhat /usr/lib/jvm/java/jdk1.6.0_32/bin/jhat 300
sudo update-alternatives --install /usr/bin/jinfo jinfo /usr/lib/jvm/java/jdk1.6.0_32/bin/jinfo 300
sudo update-alternatives --install /usr/bin/jmap jmap /usr/lib/jvm/java/jdk1.6.0_32/bin/jmap 300
sudo update-alternatives --install /usr/bin/jrunscript jrunscript /usr/lib/jvm/java/jdk1.6.0_32/bin/jrunscript 300
sudo update-alternatives --install /usr/bin/jsadebugd jsadebugd /usr/lib/jvm/java/jdk1.6.0_32/bin/jsadebugd 300
sudo update-alternatives --install /usr/bin/jstack jstack /usr/lib/jvm/java/jdk1.6.0_32/bin/jstack 300
sudo update-alternatives --install /usr/bin/jstat jstat /usr/lib/jvm/java/jdk1.6.0_32/bin/jstat 300
sudo update-alternatives --install /usr/bin/jstatd jstatd /usr/lib/jvm/java/jdk1.6.0_32/bin/jstatd 300
sudo update-alternatives --install /usr/bin/keytool keytool /usr/lib/jvm/java/jdk1.6.0_32/bin/keytool 300
sudo update-alternatives --install /usr/bin/native2ascii native2ascii /usr/lib/jvm/java/jdk1.6.0_32/bin/native2ascii 300
sudo update-alternatives --install /usr/bin/orbd orbd /usr/lib/jvm/java/jdk1.6.0_32/bin/orbd 300
sudo update-alternatives --install /usr/bin/pack200 pack200 /usr/lib/jvm/java/jdk1.6.0_32/bin/pack200 300
sudo update-alternatives --install /usr/bin/policytool policytool /usr/lib/jvm/java/jdk1.6.0_32/bin/policytool 300
sudo update-alternatives --install /usr/bin/rmic rmic /usr/lib/jvm/java/jdk1.6.0_32/bin/rmic 300
sudo update-alternatives --install /usr/bin/rmid rmid /usr/lib/jvm/java/jdk1.6.0_32/bin/rmid 300
sudo update-alternatives --install /usr/bin/rmiregistry rmiregistry /usr/lib/jvm/java/jdk1.6.0_32/bin/rmiregistry 300
sudo update-alternatives --install /usr/bin/schemagen schemagen /usr/lib/jvm/java/jdk1.6.0_32/bin/schemagen 300
sudo update-alternatives --install /usr/bin/serialver serialver /usr/lib/jvm/java/jdk1.6.0_32/bin/serialver 300
sudo update-alternatives --install /usr/bin/servertool servertool /usr/lib/jvm/java/jdk1.6.0_32/bin/servertool 300
sudo update-alternatives --install /usr/bin/tnameserv tnameserv /usr/lib/jvm/java/jdk1.6.0_32/bin/tnameserv 300
sudo update-alternatives --install /usr/bin/unpack200 unpack200 /usr/lib/jvm/java/jdk1.6.0_32/bin/unpack200 300
sudo update-alternatives --install /usr/bin/wsgen wsgen /usr/lib/jvm/java/jdk1.6.0_32/bin/wsgen 300
sudo update-alternatives --install /usr/bin/wsimport wsimport /usr/lib/jvm/java/jdk1.6.0_32/bin/wsimport 300
sudo update-alternatives --install /usr/bin/xjc xjc /usr/lib/jvm/java/jdk1.6.0_32/bin/xjc 300
通过这一步将我们安装的jdk加入java选单。
然后执行:
#!/bin/bash
echo 2 | sudo update-alternatives --config java
echo -e 'n'
echo 2 | sudo update-alternatives --config javac
echo -e 'n'
echo 2 | sudo update-alternatives --config javah
echo -e 'n'
echo 2 | sudo update-alternatives --config jar
echo -e 'n'
echo 2 | sudo update-alternatives --config javap
echo -e 'n'
echo 2 | sudo update-alternatives --config jps
echo -e 'n'
echo 2 | sudo update-alternatives --config jconsole
echo -e 'n'
echo 2 | sudo update-alternatives --config javadoc
echo -e 'n'
echo 2 | sudo update-alternatives --config appletviewer
echo -e 'n'
echo 2 | sudo update-alternatives --config apt
echo -e 'n'
echo 2 | sudo update-alternatives --config extcheck
echo -e 'n'
echo 2 | sudo update-alternatives --config idlj
echo -e 'n'
echo 2 | sudo update-alternatives --config jarsigner
echo -e 'n'
echo 2 | sudo update-alternatives --config jdb
echo -e 'n'
echo 2 | sudo update-alternatives --config javaws
echo -e 'n'
echo 2 | sudo update-alternatives --config jhat
echo -e 'n'
echo 2 | sudo update-alternatives --config jinfo
echo -e 'n'
echo 2 | sudo update-alternatives --config jmap
echo -e 'n'
echo 2 | sudo update-alternatives --config jrunscript
echo -e 'n'
echo 2 | sudo update-alternatives --config jsadebugd
echo -e 'n'
echo 2 | sudo update-alternatives --config jstack
echo -e 'n'
echo 2 | sudo update-alternatives --config jstat
echo -e 'n'
echo 2 | sudo update-alternatives --config jstatd
echo -e 'n'
echo 2 | sudo update-alternatives --config keytool
echo -e 'n'
echo 2 | sudo update-alternatives --config native2ascii
echo -e 'n'
echo 2 | sudo update-alternatives --config orbd
echo -e 'n'
echo 2 | sudo update-alternatives --config pack200
echo -e 'n'
echo 2 | sudo update-alternatives --config policytool
echo -e 'n'
echo 2 | sudo update-alternatives --config rmic
echo -e 'n'
echo 2 | sudo update-alternatives --config rmid
echo -e 'n'
echo 2 | sudo update-alternatives --config rmiregistry
echo -e 'n'
echo 2 | sudo update-alternatives --config schemagen
echo -e 'n'
echo 2 | sudo update-alternatives --config serialver
echo -e 'n'
echo 2 | sudo update-alternatives --config servertool
echo -e 'n'
echo 2 | sudo update-alternatives --config tnameserv
echo -e 'n'
echo 2 | sudo update-alternatives --config unpack200
echo -e 'n'
echo 2 | sudo update-alternatives --config wsgen
echo -e 'n'
echo 2 | sudo update-alternatives --config wsimport
echo -e 'n'
echo 2 | sudo update-alternatives --config xjc
echo -e 'n'
注意一、java是小写,这个博客有些自动转变为首字母大写了
注意二、如果是两个jdk切换的,上面最好都执行一遍,不然有各种各样问题。如果只update java javac javap这几个是不行的,我就吃过亏了。
最后
以上就是多情毛豆为你收集整理的Ubuntu14.04 切换jdk1.6和open jdk1.7编译环境的全部内容,希望文章能够帮你解决Ubuntu14.04 切换jdk1.6和open jdk1.7编译环境所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复