8

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:

  1. 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)
  2. 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?
  3. 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?

5 Answers 5

3

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.

1
  • 5
    Could you summarize the article here? We prefer you don't just link articles here. Commented Feb 12, 2012 at 16:25
14

This is the more simple way, when you get this error:

package jdk.... (which is newer than jdk...) is already installed

Use the --force flag to install multiple versions.

So for example:

sudo rpm -ivh --force jdk-6u35-linux-amd64.rpm
0
2

jdk-7u2-linux-x64.rpm is newer than jdk-6u30-linux-amd64.rpm and the RPM package management tool is smart enough to overwrite it with the newer release.

The easiest way to install sun java 6 and sun java 7 side-by-side is to download the Java tarballs from Oracle and extract them into /opt

1

I think Dejan is correct about installing the Java tarballs instead of the RPM. If you set up your JAVA_HOME and PATH correctly most uses will not need the additional setup that the RPM installation gives you (see this page for details of what jexec actually does).

One problem might be that some versions of the JDK do not make a tarball (*.tar.gz) available but instead just give you a *-rpm.bin and a *.bin. In this case the *.bin file is actually just a self extracting archive that results in the usual JAVA_HOME directory when you run it.

0

To install Java Runtime Environment on Fedora, Oracle Linux, Red Hat Enterprise Linux, etc.

# yum install java-1.7.0-openjdk

To intall package to developing programs using Java on Fedora, Oracle Linux, Red Hat Enterprise Linux, etc.

# yum install java-1.7.0-openjdk-devel

from http://namhuy.net/1195/how-to-install-oracle-java-jdk-7.html

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .