Howto: Sun Java on Fedora 7

fedora-logo-bubble
For legal reasons Sun’s Java is not included with Fedora 7 yet. However, with a bit of effort you can install it in a sane way.

The stress is on “a sane way” because the different Java versions could interfere with each other. Also, if you do it the wrong way, your java might be upgraded to the new, Fedora own version gcj.

However, before you start you should be sure that you really need Sun’s Java: read the Java FAQ from the Fedora project and also the information about the current state of OpenJDK on Fedora.
Also, first look at the Current Issues mentioned below before you start following this Howto!

The main part of this howto is taken from Jpackage’s help pages, which are much shorter and not distribution specific.

Download and Install

Here are the steps you have to do:
Prepare your system by installing necessary build tools (yes, you do have to compile stuff, unfortunately): yum -y install rpmdevtools. Also, make sure the package jpackage-utils is installed, which should be default.

Afterwards, download the latest java-1.x.0-sun-1.x.0.x-1jpp.nosrc.rpm package from the non-free branch at jpackage. In this case I took the 1.5.0 file.
It is a source rpm file, therefore it will install itself into /usr/src/redhat/... if installed as root, or into the local package build environment if installed as user.
Afterwards, check the given spec file java-1.x.0-sun.spec which is in .../SPECS or similar but in your home directory. Again, in my case it was a 1.5.0 file.
Now you have to download the appropriate java bin file from Sun – and this can be a bit tricky. In the worst case check the mentioned spec file for any link (search for the string http) – in my case I found the needed binary here.
Take the SDK and download the binary, not the self extracting RPM, to the .../SOURCES directory. Make also sure that the minor numbers of the binary are ok with the numbers given in the spec file: in my case the binary had the minor version 1.5.0-12, while the spec file defined the buildver 11. Correct this if needed.

Afterwards, recreate the java rpm: rpmbuild -ba java-1.x.0-sun.spec. You should find your new java binary in .../RPMS/i586. If they are not there, something went wrong, and you should hurry over to the next Fedora specialized forum.

However, if it did work, you can now install them. There might be some dependencies, solve this by using yum:
yum --nogpgcheck localinstall java*.rpm
You need the no-gpg option here because your local created rpms are not signed, of course.

Configure your system

After the install your basic system should already be configured:
$ java -version
java version “1.5.0_12″
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode)

If this did not happen for any reason, change the default java system to Sun’s: /usr/sbin/alternatives --config java

You also might want to install the Firefox/Mozilla plugin:
ln -s /usr/lib/jvm/java-1.5.0-sun-1.5.0.12/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so

Current Issues

This way has one current issue: the spec file calls the mkfontdir executable at the wrong place, resulting in an error during install of the java-fonts package. However, patching a spec file would go beyond this short point&click howto (although it is already a bit beyond that).

2 thoughts on “Howto: Sun Java on Fedora 7

  1. Pingback: WP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s