如何在 Ubuntu 中将 Java 从 1.6.0 降级到 1.5.0?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/672795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I downgrade Java from 1.6.0 to 1.5.0 in Ubuntu?
提问by XCH
I need to downgrade Java in Ubuntu. Current version is 1.6.0, I have to use JDK 1.5.0 for my Android platform.
我需要在 Ubuntu 中降级 Java。当前版本是 1.6.0,我的 Android 平台必须使用 JDK 1.5.0。
How to do it? Remove it and reinstall?
怎么做?删除并重新安装?
回答by esharp
Late answer but it may help someone out there:
迟到的答案,但它可能会帮助那里的人:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
sudo apt-get update
sudo apt-get install sun-java5-jdk
then you can see java5 when you
然后你就可以看到java5了
sudo update-java-alternatives -l
回答by lindelof
update-java-alternativesis your friend:
update-java-alternatives是你的朋友:
$ sudo update-java-alternatives -l
java-1.5.0-sun 53 /usr/lib/jvm/java-1.5.0-sun
java-6-sun 63 /usr/lib/jvm/java-6-sun
Then select the Java version you want. E.g., to seletc Java 1.5, do
然后选择您想要的 Java 版本。例如,要选择 Java 1.5,请执行
$ sudo update-java-alternatives -s java-1.5.0-sun
Make sure first that you have the correct Java packages installed.
首先确保您安装了正确的 Java 包。
See the Ubuntu Java pagefor more details.
有关更多详细信息,请参阅Ubuntu Java 页面。
回答by Mike Reedell
Back in the stone age (2000-2001) on Solaris we'd install both versions side by side (/usr/local or /opt) and have a bash script to change JAVA_HOME to the version we wanted to use. Easy peasy. Just make sure JAVA_HOME is in your PATH and possibly your LD_LIBRARY_PATH.
回到 Solaris 上的石器时代(2000-2001),我们将并排安装两个版本(/usr/local 或 /opt),并使用 bash 脚本将 JAVA_HOME 更改为我们想要使用的版本。十分简单。只需确保 JAVA_HOME 在您的 PATH 中,并且可能在您的 LD_LIBRARY_PATH 中。

