Tuesday, June 24, 2008

Installing Sun's Java JRE and JDK on Fedora 5

So for the last couple of days, I've been trying to get Hadoop working on my computer at work, which runs Fedora. Monday (yesterday), I found out that the source of my troubles had to do with the fact that Hadoop requires Sun's Java. Fedora, by default, comes with Gnu's Java.This would be, in most cases, ok, as Gnu's Java mimics Sun's Java and has most of the same functionality. However, certain projects (like Hadoop) requires Sun's Java, so it's a good idea to try and have both on the system.

Installing Java on Fedora is a pain. No one guide online helped me successfully install the damn thing onto my work machine, which led to quite a bit of frustration. However, since things seem to be working correctly (finally!), I thought I would share my procedure with all of you who may have to do this at some point. Even though the majority of my code posts concern Ubuntu, I think this is a worthwhile diversion.

To install Java properly (for the coders out there), there are two steps: i.) The Java Run Time Environment (JRE) and ii.) The Java Developer's Kit (JDK). Most of the instructions I'm putting here is an amalgamation of instructions found on two sites, both of which had some instructions that worked for me, and others that did not.

----

Before we begin, Make sure your System is Completely Up to Date This is CRUCIAL. All the following instructions probably will not work properly if your Fedora install is not properly updated. One thing that slowed me down quite a bit is that I initially did not do this step.

INSTALLING THE JAVA RUNTIME ENVIRONMENT (JRE)

1. Enter root mode by typing in
su

While I imagine it is possible to install this stuff locally, having root access is ideal.

2. Make sure that your system has rpmdevtools and jpackage-utils. You can install these by typing:

yum -y install rpmdevtools
yum -y install jpackage-utils

3. Next grab the jpackage key and set up the jpackage repositories for yum

rpm --import http://jpackage.org/jpackage.asc
cd /etc/yum.repos.d
wget http://www.jpackage.org/jpackage17.repo

If SUCCESS, go to step 4.
If FAIL, check to make sure that you have wget installed. Install it using:
yum -install wget

4. Get the latest Jpackage java-x-sun-xjpp.nosrc.rpm package from the non-free branch at jpackage. The package I used was this one.
Install this file by typing something akin to the following (yours may be different based on version numbers)
./java-1.6.0-sun-1.6.0.6-1jpp.nosrc.rpm

If this works, you will see it installed under /usr/src/redhat/

If SUCCESS: go to step 5.
If FAIL: Check permissions. You may have to change permissions as follows:

chmod 755 java-1.6.0-sun-1.6.0.6-1jpp.nosrc.rpm

If SUCCESS, go to step 5.
If FAIL, I cannot help you. Sorry!

5. Get the latest binary. I got mine from here. It should look something like jre-6u6-linux-i586.bin.
Move this file to the SOURCES directory. So something like,

mv jre-6u6-linux-i586.bin /usr/src/redhat/SOURCES/.

Next, rebuild the java rpm using

rpmbuild -ba java-1.x.0-sun.spec

If SUCCESS, you should now be able to see the binary in /usr/src/redhat/RPMS/i586/ . Go to step 6.
If FAIL, make sure that you are running this command in the /usr/src/redhat/SPEC/ directory. If you do not have a spec file, you did something wrong in the previous steps, or I can't help you.

6. Install the binaries in /usr/src/redhat/RPMS/i586/ by using the following command:
yum --nogpgcheck localinstall java*.rpm

If SUCCESS, go on to part 2.
IF FAIL, the most likely reason for failure is some sort of message like --nogpgcheck not a valid command for yum. Omit it then. Alternatively, you can manually go into the /usr/src/redhat/RPMS/i586/ folder and install all the rpms by double clicking on them.


INSTALLING JDK

1. Make sure you have the following packages: rpm-build and fedora-rpmdevetools. If not, install using
yum install fedora-rpmdevtools
yum install rpm-build

2. Grab the sun jdk rpm file. I got mine from here. The file should look something like: jdk-6u6-linux-i586-rpm.bin

Run the rpm by doing the following:
chmod 755 jdk-6u2-linux-i586-rpm.bin
./jdk-6u2-linux-i586-rpm.bin

If SUCCESS, you should be able to see a whole bunch of RPMs located in /usr/java/jdk1.6.0_02 and a new directory in /opt/sun . Move to step 3

3. Next, install the RPM. You'll also need a compat file from Jpackages. I got mine here. It should look something like java-1.6.0-sun-compat-1.6.0.06-1jpp.src.rpm.

Do the following:
yum --enablerepo=jpackage-generic-nonfree install java-1.6.0-sun-compat-1.6.0.06-1jpp.src.rpm

Say yes when prompted. This should complete installation of JDK.

4. Keep in mind that the default Java may still not be Sun Java. To fix this, we need one last step:

/usr/sbin/alternatives --config java

This should show two options: GIJ (the older java) and Sun's Java. On my machine it was option 2. Enter the number that corresponds to the Sun Java install and press enter.

Now, if you type in:

java -version

It should print out something like:

java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06)
Java HotSpot(TM) Client VM (build 1.6.0_06, mixed mode, sharing)


You're done!

Additionally, you'll probably want to install the mozilla plugin. Do something akin to the following
ln -s /usr/lib/jvm/java-1.6.0-sun-1.6.0/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so


And that should fix everything. Hope this post will eventually be helpful to someone. Comments welcome.

Saturday, June 14, 2008

Entracte - Texas

"Stuck on you
I've got this feeling deep down in my soul that I just can't lose
Guess I'm on my way
Needed a friend
And the way I feel about you I guess I'll be with you 'til the end
Guess I'm on my way
Mighty glad you stayed"


"Oh, the North country winters keep a gettin' me now
Lost my money playin' poker so I had to up and leave
But I ain't a turnin' back
To livin' that old life no more..."

"Suddenly I see this is what I wanna be
Suddely I see why the hell it means so much to me
'Cause this is what I wanna be
Suddenly I see why the hell it means so much to me..."



Finally in Texas. A few more days before I officially start my position as an R.A. Also the first day of a new long distance relationship. What will the future hold? Who knows? All I know is, all I can do is look forward...and some how, it will all turn out just fine.