Note: There are 2 ways to install java6 nowadays b/c java6 has been added to the repositories (multiverse)
The following method is if you have the multiverse repository
enabled/added to your /etc/apt/sources.list (I won't go covering how to
do that here)
To install:
sudo apt-get update
# To install the mozilla plugin remove the # on the next line
sudo apt-get install sun-java6-jdk #sun-java6-plugin
update-java-alternatives --list
# The line above should produce output somewhat similar to:
# java-6-sun 63 /usr/lib/jvm/java-6-sun
# Add the first part of the line above to the end of the next line
sudo update-java-alternatives --set java-6-sun
Now if you want to change java versions just do:
update-java-alternatives --list
sudo update-java-alternatives --set <one of the java versions>
----------------------------------------------------------------------------------------------------------------------------
The following method shows how to install java 6 manually (in case you
don't want multiverse repo. enabled for security reasons or if you just
want to learn how to do it)
1. Download the Java 6 SDK (Make sure you download the "Linux
self-extracting file") from
http://java.sun.com/javase/downloads/index.jsp
2. After it has finished downloading you will have a file called jdk-6-linux-i586.bin
3. Run the following in the directory that the file is located in (Change any variables as you see fit)
JDKFILE=jdk-6-linux-i586.bin
JDKFOLDER=jdk1.6.0
JDKPATH=/opt
chmod +x $JDKFILE
sh $JDKFILE
sudo mv $JDKFOLDER $JDKPATH
# Uncomment the following line to have Mozilla browsers (i.e. Firefox) load the Java 6 plugin
# ln -s $JDKPATH/$JDKFOLDER/jre/plugin/i386/ns7/libjavaplugin_oji.so ~/.mozilla/plugins
echo "export JAVA_HOME=$JDKPATH/$JDKFOLDER" >> ~/.bashrc
echo "PATH=/$JAVA_HOME/bin:/$JAVA_HOME/jre/bin:/$PATH" >> ~/.bashrc
source ~/.bashrc
Now you can test to see if java 6 is installed by running: `java -version` and `javac -version`
This should print out something similar to:
joncfoo@A3200:~$ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
joncfoo@A3200:~$ javac -version
javac 1.6.0
Now if you have other versions of Java installed and want to use them,
the easiest way to do is would be to change the JAVA_HOME variable by
doing:
export JAVA_HOME=/another/java/directory
After you have done this, just launch whatever application(s) you need under that version of Java
I hope this is straightforward and to the point. If not feel free to ask me any questions.
Ubuntu下,两种方法安装JDK6及版本间切换
最新推荐文章于 2021-02-21 13:53:58 发布
本文介绍两种安装Java 6的方法:一种是通过已启用的multiverse仓库进行安装;另一种是手动下载并配置Java 6 SDK。文章详细说明了每一步操作,并提供测试安装成功与否的方法。
3万+

被折叠的 条评论
为什么被折叠?



