What's is the most efficient way to install multiple concurrent Java JDK versions on the same Linux machine?

I need Java5 whilst my current Ubuntu 9.10 Karmic comes loaded with Java6.

I know I could setup a VM for this but I am looking for alternatives.

link|improve this question

feedback

1 Answer

up vote 1 down vote accepted

If you download the linux binary from Sun you can install it in whatever directory you like. Then just reference those libs in your code, and you're good to go.

With the binary installer, it'll create its own named subdirectory (e.g. in your example, /usr/java/jdk1.5.0_), so you can download as many as you want, and they'll line themselves up in appropriately named sub-drectories.

The main java binary lives in /usr/bin, so if you want to replace that to the point where when you type "java" it accesses your java, and not that one, you just move the old one out of /usr/bin, and link your new one in there. Typing which java will tell you what the default java on your system is.

@jldupont: When I think of concurrent installs, I think of multiple versions installed on the same machine, which my method will absolutely give you. I have about 12 versions of java installed on my production box to handle hand-me-downs from corporate that haven't yet been updated.

However when you type "java" you're only going to get one version of java, since that's what's in '/usr/bin'...You'd have to type something like '/usr/java/jdk1.5.1/bin/java' to get a specific java binary that's not the system default.

link|improve this answer
Thanks but I need concurrent installs. How do I do that? – jldupont Apr 28 '10 at 14:49
thanks. I have now installed JDK5 in /opt and wrote myself a bash script to setup the environment variables... it looks has it works. I thought it would be more painful than this! – jldupont Apr 28 '10 at 15:09
@jldupont: Actually that's one of the things I love about linux...Since there is no registry to get in the way, you can install the same thing a hundred times, and it's not a problem as long as you're making sure to not over-write common files. I know a lot of people who run (for example) multiple different versions of Apache. I myself tend to run multiple versions of Perl and Java. – Satanicpuppy Apr 28 '10 at 15:29
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.