Difference between revisions of "Getting Java 1.5 running"
m (3 revision(s))
Revision as of 19:33, 12 July 2007
After getting my Kuro HG box and seeing what could be done, I wanted to port some of my HA (Home Automation) software to it. The software is platform neutral and implemented in Java. Unfortunately, the only PPC based modern Java (1.5) would not work with the stock Kuro image. Thus began the process of figuring out what needed to be done. What follows is the step by step process I used to put a modern kernel and modern Java 1.5 on my Kuro box. My Java software has been running for over a month without any hitches.
If you need only Java 1.4.2, skip all this and simply install the Sylver project files. The result is a very complete system with the IBM 1.4.2 (full java, not the gcj stuff that never works) and doesn't involve any more machinations than downloading the files, using unrar to string them together and then untaring the file in the root directory. Well, you do have to format the root directory a bit larger, but that's pretty easy. Follow the links on the Wiki for more info.
The only Java 1.5 I could find for the PPC platform was the IBM based kit. This in turn required GLIBC 2.3 or later to run. Unfortunately, the stock Kuro HG distro runs something like 2.2.3 and you cannot just upgrade it. If you do, you'll not be able to boot because the kernel (which is in the Flash ROM) won't work with 2.3+ (that means no init task, no scripts, no nothing). Blah, blah, pain, suffering, etc...
Unfortunately, this means the only option is to install a newer distro based on the 2.3 or later GLIBC and to do that, you've got to instal U-boot (no strictly true, but the least painful of all the alternatives -- it relieves the Kuro from the last of it's native Linux 2.4 burden).
I spent a lot of time trying to avoid having to install Uboot -- in part, because I didn't want to take a chance at bricking my unit, but mostly because it looked just too damn complicated. You can chase around details on using loader.o modules and uloader.o modules that either don't work (built for slightly different kernels) or need to be built from source. But then you'll find you need to build the loaders with the GCC 2.95 environment and then U-Boot with a later GCC 3.x environment. Blah, blah, more pain, more suffering, etc.
In the end, it's not that tough to just follow the directions others have laid out for you (see below) and really, if you're willing to follow those instructions, installing U-boot will take a few minutes and is easy.
As for a more modern distro, I don't want to get into a war about which is best. I chose the excellent fedora core 5 distro that is on the kurobox.com site. Works well, I know fedora and I know it has a modern GLIBC.
Kuro Upgrade Process
Go to the U-boot Wiki page here: http://www.kurobox.com/mwiki/index.php/HOWTO_U-Boot
Scroll down to find the install that matches what you have. If you haven't yet modified your Kuro HG much, scroll down to the part on HG and 2.4 kernel. Just do what it says -- download the file, install it using dd, you *might* be able to use cmp, though I often found it wasn't available.
This is the dangerous part and you should read all the scary warnings including how you can brick your unit (i.e. make it into a brick -- useless paper weight). The warnings are appropriately stern and scary, but as long as you follow the rules, read and understand exactly what you are going to do (do NOT blindly just "pick something close") and triple check your command lines before hitting return, you shouldn't have a problem.
Including reading, this will probably take your 15 minutes or less.
Install Fedora Core 5
Go to the Fedora Core 5 page here http://www.kurobox.com/mwiki/index.php/Install_Fedora_Core_5
The FC5 notes presume you are already in EM mode. If you are not, there are a few ways in. Since you will probably be repartitioning the disks anyway, I found the easiest way in like this (as root):
# dd if=/dev/zero of=/dev/hda count=1
Then reboot. That will invalidate the disks partition table and the Kuro will jump into EM mode when it boots. Then follow the directiions to install FC5.
I chose to reserve 25GB for the /dev/hda1 (root) partition and 1GB for /dev/hda2 (swap). That is probably serious overkill on swap, but remember we only have 128MB of RAM and, well, this is Java and -- bless it's little heart -- it's not the most petite memory consumer. I reserved the rest in /dev/hda3
Install necessary compatible libraries
In order for Java to work, you need a set of compatibility libraries that are not included in the standard FC5 distro. You can probably find this in many places, but I found what I needed at ftp://rpmfind.net/linux/fedora/core/4/ppc/os/Fedora/RPMS/compat-libstdc++-33-3.2.3-47.fc4.ppc.rpm
Don't worry about this coming from an FC4 distro -- it is fine -- these are compatibility libraries after all -- not the most current stuff.
Download this and use rpm to install it (as root) like this:
# rpm -i compat-libstdc++-33-3.2.3-47.fc4.ppc.rpm
Tune the FC5 install
The FC5 install you now should be running is really quite nifty in it's thoroughness. However, if we are going to be running Java, we need to strip out all the stuff that isn't strictly necessary. What is "necessary" is up to each person, but I'll list what I did.
I turned off a bunch of services like cups (printing), sendmail, bluetooth, appleshare, X font server, anacron and atd (crond is enough for me). I also removed the GCC based Java as it really is just taking up space and adding confusion.
Here's how I turned off things:
# chkconfig --level 12345 sendmail off # chkconfig --level 12345 bluetooth off # chkconfig --level 12345 dund off # chkconfig --level 12345 hidd off # chkconfig --level 12345 pand off # chkconfig --level 12345 cups off # chkconfig --level 12345 cups-config-daemon off # chkconfig --level 12345 anacron off # chkconfig --level 12345 atd off # chkconfig --level 12345 xfs off # chkconfig --level 12345 avahi-daemon off # chkconfig --level 12345 avahi-dnsconfd off
Removing the GCJ java is a bit "scarier" because, like a infected tooth, it doesn't want to just "come out". So I forced it. Yeah, bad form, but frankly, anything that really depended on it should be OK depending on the replaced Java. Here's what I did
# rpm -e --nodeps java-1.4.2-gcj-compat
Next, you need to edit /etc/profile to find the new Java (even though we don't have it yet, lets get it out of the way now). I used vi to edit, some may use nano (which, unfortunatly, has a nasty habit of wrapping long text line and breaking things). Anyway...
Scroll down to the line that looks like:
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
and **BEFORE** that line, add the following:
export JAVA_HOME=/usr/local/java pathmunge $JAVA_HOME/bin
Finally, if you have setup /dev/hda3 as the "big disk" for storage, you'll want to add a line to /etc/fstab to mount it (by default, it's not mounted). Add a line like this to the end of /etc/fstab
/dev/hda3 /mnt ext3 defaults 0 0
That will mount your big disk at /mnt when the system starts up.
Install IBM Java 5
This one is, in my opinion, an unnecessary pain in the butt. IBM won't let you download it without registering first. So you'll register and fill in the minimum info. Then when you go to download, it'll say you haven't filled in enough info and make you add more (like company name and other stuff). Then, when that is done, by default, they'll try to start some moderately obnoxious "Download Manager". Bah! Just give me a link.
Start your journey here http://www-128.ibm.com/developerworks/java/jdk/linux/download.html You won't get too far before you have to register. Select that you want the "32 bit iSeries/pSeries" download. When you finally are able to download, if you look carefully, you'll see a link for an "HTTP Download". Take that to bypass the "Download Manager" thingy.
You only need the JRE download if you are just foing to run things. It's a much smaller download than the SDK. However, if you want to compile Java code and/or the app you want to use requires it (i.e. thinks like J2EE and Tomcat based apps), you'll need the SDK.
To install it (once it was on my kurobox, in my case, in /tmp), do the following as root:
# cd /usr/local # tar xzf /tmp/ibm-java2-sdk-50-linux-ppc.tgz # ln -s ibm-java2-ppc-50 java
Note: I downloaded the SDK for my uses. If you use the JRE, it will be almost the same, with a few obvious changes to the names.
You are done!
I'd do a nice reboot to clean out the disabled services and get tne environment setup. After the reboot, you should be able to type
java -version and get confirmation the JVM is working and running at 1.5.
You should be able to run any Java app that does NOT use a GUI now.