This is what I would like to achieve, but I'm failing (I'm a newbie in Linux).
I have a Fedora 16 box (64 bit) and would like to install multiple versions of oracle java (java 6 and java 7 for the moment).
I'm trying to install java using the rpm software and I would like to install both of them under /opt
.
I downloaded the required packages from the Oracle site:
jdk-6u30-linux-x64-rpm.bin
jdk-7u2-linux-x64.rpm
and extracted the rpm package from inside the .bin
file running
./jdk-6u30-linux-x64-rpm.bin -x
obtaining the following situation:
jdk-6u30-linux-amd64.rpm
jdk-7u2-linux-x64.rpm
Then I looked inside jdk-6u30-linux-amd64.rpm
with:
rpm -qpl ~/Downloads/jdk-7u2-linux-x64.rpm
and obtained that java 6 will install its files into:
/etc (some files)
/usr/java/jdk1.6.0\_30 (the majority of the files)
In a similar way java 7 will install into:
/etc
/usr/java/jdk1.7.0\_02
Because I want to install into /opt
I tried to install using rpm relocation.
Both packages seem to be rpm-relocatable, in fact:
rpm -qpi ~/Downloads/jdk-6u30-linux-amd64.rpm | grep -i reloc
gives as result
Relocations : /usr/java
and
rpm -qpi ~/Downloads/jdk-7u2-linux-x64.rpm | grep -i reloc
gives as result
Relocations : /usr/java
Attempt 1 (install java 6 and then java 7)
sudo rpm -i --relocate /usr/java=/opt/java ~/Downloads/jdk-6u30-linux-amd64.rpm
this runs almost smoothly because rpm says
ln: failed to create symbolic link '/usr/java/jdk1.6.0\_30': No such file or directory`
rpm -q jdk
says
jdk-1.6.0\_30-fcs.x86\_64_ ... OK!
then
sudo rpm -i --relocate /usr/java=/opt/java ~/Downloads/jdk-7u2-linux-x64.rpm
fails tremendously saying:
file /etc/init.d/jexec from install of
jdk-2000:1.7.0\_02-fcs.x86\_64* conflicts with file from package
jdk-2000:1.6.0\_30-fcs.x86\_64*
Attempt 2 (install java 7 and then java 6)
having yet installed java 6 I'll remove it first:
sudo rpm -e jdk*
sudo rpm -q jdk*
gives:
package jdk is not installed* <- OK, uninstalled!
then let's try installing java 7
sudo rpm -i --relocate /usr/java=/opt/java ~/Downloads/jdk-7u2-linux-x64.rpm*
gives the usual error:
ln: failed to create symbolic link '/usr/java/jdk1.7.0_02': No such file or directory`*
and now java 6
sudo rpm -i --relocate /usr/java=/opt/java ~/Downloads/jdk-6u30-linux-amd64.rpm*
fails saying two things:
package jdk-2000:1.7.0\_02-fcs.x86\_64 (which is newer than jdk-2000:1.6.0\_30-fcs.x86\_64) is already installed*
and
file /etc/init.d/jexec from install of jdk-2000:1.6.0\_30-fcs.x86\_64
conflicts with file from package jdk-2000:1.7.0\_02-fcs.x86\_64*
My questions are:
- symbolic link creation problem:
is there a way to fix it? the installation process seems not to be aware that I
tried to use
the relocation mechanism, even if the package is relocatable (as far as I see) - am I missing something in the installation process? Is it really possible to have both java 6 and java 7
on the same Linux machine? How? What am I doing wrong? - Is there another way to achieve my goal?
PS: this is my first question here. I apologize in advance if something is wrong (from my English to the formatting and anything)
PS2: I tried to add the tag sun-java7-jdk to this question but I haven't enough reputation to do it… should this tag be created?
Best Answer
I had similar problems getting Oracle java and OpenJDK to exist side by side on Fedora 16. I followed the guide on If not True then False and it worked perfectly.