4 ms·
This is for Ubuntu < 11.10. They're already gone in the 11.10 repositories. I just went through the ordeal of manually installing and setting up JDK6 and JDK7
by SkyMarshal 15y ago
This is for Ubuntu < 11.10. They're already gone in the 11.10 repositories. I just went through the ordeal of manually installing and setting up JDK6 and JDK7 alongside OpenJDK. Here's how, along with some useful update-alternatives scripts:
1. Download from Oracles' site http://www.oracle.com/java http://www.oracle.com/java. extract, and copy the extracted folder to /usr/lib/jvm (where openjdk is installed by default).
2. Change the default-jvm soft link to the new jdk:
> cd /usr/lib/jvm
> sudo rm default-jvm
> sudo ln -s jdk1.6.0_30 default-jvm
3. In .profile or .bash_profile add:
export JAVA_HOME=/usr/lib/jvm/default-jvm
(no need to add $JAVA_HOME/bin to your PATH, update-alternatives takes care of that by linking it to /usr/bin)
4. Add the new JDK to /etc/alternatives with update-alternatives command. The trick here is to slave all the jdk1.6.0_30/bin supporting programs to jdk1.6.0_30/bin/java, so that changing from one java to another also changes all the supporting programs as well. Without slaving them, you have to call update-alternatives --config on all of them separately, and there are quite a few as can be seen in the scripts below.
https://raw.github.com/byrongibson/scripts/master/install/java/java-alt-install-oraclejdk6-server-allslave.sh https://raw.github.com/byrongibson/scripts/master/install/ja...
https://raw.github.com/byrongibson/scripts/master/install/java/java-alt-install-oraclejdk7-server-allslave.sh https://raw.github.com/byrongibson/scripts/master/install/ja...
https://raw.github.com/byrongibson/scripts/master/install/java/java-alt-remove-all.sh https://raw.github.com/byrongibson/scripts/master/install/ja...
That's it. This lets you install JDK6 and JDK7 side-by-side with OpenJDK (which I apt-get installed first, fwiw), and switch between them with a quick update-alternatives --config, and changing of the default-java soft link.
Doing it this way lets you install any number of JDK versions or minor versions side-by-side, and easily switch among them, or upgrade from one to another, and switch back if the new version borked whatever you were running on it.
Of course, no more automatic security updates, so you have to keep an eye on that and download the new Oracle JDK minor/update versions when they're released, but on the other hand it's much easier to roll back if an update breaks something, since the prior working version is still there and just and update-alternatives away.
- deleted 15y ago[deleted]
- tomjen3 15y agoSorry, but that is way to complicated. I remembered there was an unofficial repository for Mandrake once upon a time (about Mandrake 8 or so) which had a bunch of software that allowed you to watch DVDs, play MP3s, etc. (They also had hotgirl). It was hosted by a bunch of crazy people (I seem to recall them being French). So what I just really want to know is if anybody knows of an alternative repository?
- SkyMarshal 15y agoIt's actually really simple, it just looks complicated on the first pass. Try it, on a virtual machine test box if necessary, you'll see. 90% of the work in this method is getting the update-alternatives scripts right, and that's already done. And the ability to painlessly rollback is more than worth it.
- tomjen3 15y agoBy too complicated I mean I have to think about it, because Ubuntu broke something that previously worked. The best solution is to get somebody Oracle can't block to put them into a repository.
- pasbesoin 15y agoThank you.
- dekz 15y agoWhy is this easier than making ~/lib/java-latest softlinked to ~/lib/jdk1.6.0_30 then just re-linking to the one you want to use while having export JAVA_HOME=~/lib/java-latest in ~/*rc . At least this way it isn't ubuntu specific and you don't have to know about update-alternatives (first time for me hearing of that).
- SkyMarshal 15y agoYou could do that too, only problem I can think of is if you also want to install OpenJDK from the Ubuntu repos. Presuming that, in addition to what you said, you also add your new $JAVA_HOME/bin to your $PATH, then you'll have a namespace collision in your PATH between $JAVA_HOME/bin/java and /usr/bin/java (OpenJDK linked via /etc/alternatives/java via /usr/lib/jvm/openjdk/bin/java, which is the default install setup for openjdk, on 11.10 at least). If you're installing OpenJDK manually too, instead of via repo, or not at all, then keeping all your jdk's in ~/lib might be a better option overall.