OK. I've started this a new thread because it's now working and I figured the information might be useful to some. This probably belongs in the Wiki somewhere, but I don't have the time right now to add it and ensure that it's formatted. If someone does, then feel free, if not I'll try and add it a little later this week. At the minute it's specific to the WRT54G series, but should work with any Kamikaze (Or possibly White Russian) router. As such, I don't know if it should reside in a WRT54G specific page, or as a generic page with router-specific sections. A big thank you to Robert Lougher for creating JamVM and for his help in getting it to run on my PC, which taught me what the problems were with getting it to run on the router.
Background:
Sable-mini doesn't contain anything particularly useful for running "real" Java applications, and the full SableVM installation is too big to be installed on a WRT54G series router. In addition Sable appears to be largely unsupported, while JamVM is a live project with a good track record and support. However the JamVM package only contains the Jam-specific classes and requires the GNU classpath. This has native code which needs to be cross-compiled for the router platform.
Instructions (Assuming a working Kamikaze installation):
1. Download the Kamikaze "source" from SVN or the site. Decompress and run make menuconfig. I believe that the SDK is all that's required, but a full build will result in a working cross-compiler toolchain (You can set one up yourself, but there's no point re-inventing the wheel!)
2. Download the GNU Classpath (http://www.gnu.org/software/classpath/). Decompress somewhere.
3. Add the toolchain/bin directory (In the Kamikaze staging area, it's the one that contains the architecture specific GCC and friends) to PATH. If you don't do this, the classpath configure will silently default to building code for the build machine and noth the target.
4. Change to the Classpath directory. Create a new sub-directory ("mipsel" was a good name for me, but it doesn't matter what you use). Change to that new directory.
5. Run configure as follows:
../configure --host=mipsel-linux --prefix=/usr --disable-gtk-peer --disable-gconf-peer --disable-plugin --disable-qt-peer
The entry for host should match the prefix of the cross-compilation toolchain made by Kamikaze.
--prefix=/usr is necessary because the default is /usr/local which doesn't tie in nicely to the Kamikaze directory structure.
-disable-* These are essential to avoid attempting to link in to libraries which are not available on Kamikaze (Basically this loses you the accelerated AWT... I figure that the WRT54G's are not devices on which you want to run a framework-based windowing system.
Watch the messages from configure to check that it has found the Kamikaze toolchain.
6. Run "make". This should build the GNU classpath.
7. Create another subdirectory ("inst_temp" is as good as any). We're going to install into this directory.
8. Run:
make DESTDIR=/full/path/to/new/directory install
9. We now have a Classpath... celebrate with a beer for the time it takes to realise how much bigger this is than the available space on the router!
Paring down the Classpath. - Your methods and requirements may vary, but this worked for me.
------------------------------------
10. Create a new directory parallel to the "inst_temp" we created earlier ("staging" might be a good name). This is where we will assemble the real installation set.
11. Change to the new directory.
12. Copy usr/lib and usr/share/classpath from the original into it.
13. Change to the usr/share/classpath directory
14. Delete the examples directory and tools.zip.
15. Create a new temp directory. We're going to unzip the class files here and start "trimming". Change to the new directory and run "unzip ../glibj.zip"
16. We now have a set of directories containing the classpath itself ("java", "gnu", "sun" etc"). At this point we need to prune stuff from the tree that we don't need. This depends on your requirements. Personally, I got rid of all of javax, java.awt, java.rmi and some others. Don't forgot to track down the helper classes in "gnu" that are related to the java classes.
17. Trimming complete. From the "temp" directory, run
zip -r -9 ../glibj-sm.zip *
18. Change back to the "staging" directory and verify the size of your "small" glibj. I got mine down to around 4MB
Installing the Classpath
-------------------------------
19. There isn't enough room on the JFFS to install this "properly", so we're going to install into /tmp and use symlinks to put stuff where we need it. Building a bootstrap to download the files on startup is left as an exercise for the reader. ;-) You want to copy (scp) the whole of the lib directory and our glibj-sm.zip file. Be aware that scp will copy the targets of symlinks and not the links themselves. You will have to re-create the .so and .so.0 symlinks on the router.
20. ssh to the router.
21. Run "mkdir -pv /usr/local/classpath/lib"
22. cd /usr/local/classpath/lib
23. In this directory we need to symlink the contents of /tmp/lib. To save having to build all the symlinks every time the router is booted, I would suggest making the "classpath" directory a real directory and linking the files individually.
24. At this point in /usr/local/classpath/lib, you should have "classpath" and "security" directories and a file "logging.properties".
Running JamVM
----------------------
25. Run
jamvm -verbose -Xmx5M -Xbootclasspath/a:/tmp/glibj-sm.zip ClassToRun
-verbose is a good one to have to check that it's all running OK. It'll list the classes as they are found and linked in.
-XMx5M sets the heap to a maximum of 5M. The default for JamVM is 16M which isn't going to work on a router with 8M of available memory (After tmp has taken 8M of that!).
-Xbootclasspath/a appends our Classpath to the internal classpath. This ensures that the VM-specific classes in classes.zip are used instead of any duplicates in our Classpath.
You should find that your code runs. I've tested this with a simple Hello World application and will be porting something more complex later today. I would suggest that you install JamVM and the GNU Classpath on your PC as well, and create a similarly trimmed Classpath. That way you can test code on a host machine without having to install it to the router every time.
That's all folks!