The Source for Java Technology Collaboration
User: Password:



Cay Horstmann

Cay Horstmann's Blog

The OLPC and Java

Posted by cayhorstmann on December 31, 2007 at 09:28 AM | Comments (12)

I got an OLPC for the holiday season. No, it wasn't for the Horstmann twins—after all, it is one laptop per child, so the child must be myself. I got it through the “give one, get one program”. For $400, I got mine and a much more deserving kid somewhere out there got one as well. (Hurry if you want to get yours—the program ends today.)

Twelve years ago, in Chapter 1 of the first edition of Core Java, Gary Cornell and myself wrote this in the section entitled “Common Misperceptions about Java”:

With Java, I can replace my computer with a $500 “Internet appliance.”

Some people are betting big that this is going to happen. We believe it is pretty absurd to think that people are going to give up a powerful and convenient desktop for a limited machine with no local storage...We can envision an Internet appliance as a portable adjunct to a desktop. Provided the price is right, wouldn’t you rather have an Internet enabled telephone with a small screen to read your e-mail or see the news. Because the Java kernel is so small, Java is the obvious choice for such a telephone or other internet “appliance.”

So, now I have my $200 internet appliance. It works like a charm. I can browse the web and read my email. The keyboard is not great, but it is spillproof, which is just the thing when reading the news while the Horstmann twins are up to no good. Here is what I love about the OLPC:

  • The price. It's a steal at $200.
  • The form factor. It is small (but not too small) and rugged.
  • The screen. It morphs from a standard backlit color screen into a grayscale screen that can be read in bright sunlight—very nifty!
  • The silence. There is no fan and no whirring hard disk.
  • The openness. I don't have an epic power struggle against a manufacturer who cares more about “digital rights limitations” than my ability to use the device.

But Gary and myself were wrong in one teensy detail. The internet appliance is not Java-powered. The OLPC uses Linux, and the browser is Firefox, converted to the kid-friendly “Sugar” environment.

I am not too thrilled about that part. I'd love to put more software onto the OLPC, but not if it means doing it in C++ and some goofball X11 window manager. I am glad that other people don't feel as squeamish about these things as I do, but it made me think about the role of Java in this new class of devices.

I really believe that the OLPC, the Asus Eee, and the Everex gPC, are the forerunners of a new category of devices that are truly useful and important. What would it take for Java to be an essential part of these devices?

First off, these are not crippled ME devices. I ran Java SE apps on the OLPC (see below for details), and the performance was ok for JEdit and the Violet UML editor. I didn't try Netbeans :-)

So, why didn't the OLPC folks put Java on the machine? A major reason is surely that Java was not open source software when the OLPC was designed.

Then there is the issue of SE bloat. Or maybe not. I thought about what parts of SE one could place into separate extension libraries. There is RMI/CORBA. And the sound stuff that very few people use because it isn't very good. What else? Maybe SQL, web services, scripting, NIO? Beyond that, I don't think one can drop entire packages. Some crypto is needed by platform security. Some XML is used by logging and preferences. Last Java One, I heard some people say that they were looking into this issue, and I am curious what they found. My hunch is that there may be a smallish core for console applications, but as soon as you let in Swing, you are probably at 2/3 of rt.jar.

Anyway, there has been this huge effort to make Java play nicely with Vista's throbbing buttons. Maybe that's yesterday's battle. The OLPC shows quite starkly what you can do for $200 if you dispense with those throbbing buttons and instead give people something more useful for a specific task—such as browsing the web around the house and in the garden. I once read that when electric motors were first sold, they were expensive high-tech equipment. People would buy one motor that could be attached to various devices. Maybe one day people will chuckle when they hear about the personal computer era when we bought one computer to run all sorts of programs on a single device.


This appendix contains the gory details—skip it if you don't have an OLPC.

To install Java, go to a non-XO machine and visit http://java.com/en/download/linux_manual.jsp

Download "Linux RPM (self-extracting file)". Use scp or a USB stick to move to the XO. Then ssh into the root account of the XO, and run

chmod a+x jre-6u3-linux-i586-rpm.bin 
./jre-6u3-linux-i586-rpm.bin 

(The exact name may differ.)

By the way, here is the result of running df before

mtd0 1048576 346408 702168 34% /

and after

mtd0 1048576 428820 619756 41% /

On another computer, use ssh -X to get a shell on the XO. (If you use Cygwin, be sure to have X11 installed.) Try running a Web Start program:

javaws http://www.horstmann.com/violet/violet.jnlp

If you get an error message such as

java.lang.UnsatisfiedLinkError: /usr/java/jre1.6.0_03/lib/i386/libdeploy.so: libstdc++.so.5: cannot open shared object file: No such file or directory

then run

yum install compat-libstdc++-33

You should now be able run Java applications and have them show up on your other computer.

Unfortunately, on the XO itself, the Matchbox window manager seriously breaks Java applications. JEdit shows up, but the main window is too small and the menus and dialogs are at the wrong places. Violet doesn't seem to work at all. This will presumably get worked on in the future.

I then tried to get the Java Plug-in working in the usual way:

cd /usr/lib/mozilla/plugins/
ln -s /usr/java/jre1.6.0_03/plugin/i386/ns7/libjavaplugin_oji.so

Unfortunately, the plug-in didn't show up when visiting about:plugins

I got these errors in /home/olpc/.sugar/default/logs/org.laptop.WebActivity?-1.log

LoadPlugin: failed to initialize shared library libXt.so [libXt.so: cannot open shared object file: No such file or directory]
LoadPlugin: failed to initialize shared library libXext.so [libXext.so: cannot open shared object file: No such file or directory]
LoadPlugin: failed to initialize shared library /usr/java/jre1.6.0_03/plugin/i386/ns7/libjavaplugin_oji.so [/usr/java/jre1.6.0_03/plugin/i386/ns7/libjavaplugin_oji.so: undefined symbol: _ZTVN10__cxxabiv121__vmi_class_type_infoE]

I got rid of the first two error messages by making symlinks /usr/lib/libXt.so -> libXt.so.6 and /usr/lib/libXext.so -> libXext.so.6

But the third message persisted. Apparently, I am not the only onewith this problem, but I could not find a solution. (Setting JAVA_HOME in /etc/profile didn't help.)

Just to make it very clear—do not buy an OLPC today to run Java applications. My experiment demonstrates that the machine has sufficient power to do so, but the software needs work.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • The OLPC folks chose Python as their platform, which I think was a good choice for this specific project. Python has always been open source, it comes with its own VM with a smaller footprint and a --MUCH-- simpler and easier to learn programming language than Java, especially for the target audience, which are children. Sugar itself actually is written in Python, I don't think they used much, if any, C or C++ on this device. From this perspective, and when you are not a hardcore Java developer who wants to port some already existing code, it looks like a major step backwards if you want to use Java on this device instead of Python. Java only makes things more complicated in this scenario, without providing any benefit at all.

    Posted by: winfriedmaus on December 31, 2007 at 01:30 PM

  • winfriedmaus--I don't think it is quite fair to say that "Python is the platform". The platform is Sugar. I agree that Sugar is less ambitious than JavaSE, which may or may not be a good thing. At any rate, the good news is that JavaSE can run effectively on such a device, and that we should be prepared for these devices to become more prevalent.

    Posted by: cayhorstmann on December 31, 2007 at 02:43 PM

  • The EeePC comes with Java 5 pre-installed apparently, works fine. Regarding Sugar, I'm not really sold on the stability (I see the bug reports every week) or educational value (Python was not designed with kids in mind) of it myself, but I wish them the best.

    Posted by: dug on December 31, 2007 at 04:07 PM

  • From what I have read, the Sugar platform is written in and on top of Python, which arguably is as much a platform of its own as Java SE is, and they share many concepts. But I don't want to debate words and names. Python has less complexity than Java, which generally is a good thing. It certainly was not developed with children in mind, but neither was Java or any other language except for Logo. You probably cannot build something like Sugar with Logo, but I remember that more than twenty years ago the teachers at my school used it very successfully for teaching programming to teenagers. My guess is that Python was just the best compromise for this specific project. I am not a Python fan, by the way, I think there are several things wrong with it, but I am not a Java fan either. They're both just tools with individual weaknesses and strengths, and sometimes one is the better solution for a specific problem than the other one. However, they could have combined both worlds and used Jython. ;-) Happy new year 2008!

    Posted by: winfriedmaus on December 31, 2007 at 04:50 PM

  • Cay,

    My OLPC arrived, and it's a blast.

    I agree with you that OLPC is not just a toy, it's got plenty of potential... although I must admit that all of the software seems to be of the "work in progress" variety. Sadly, honed Java skills aren't going to be able to do much to correct that... If you wan't to help out you'll probably have to master Python.

    -JohnR

    Posted by: johnreynolds on December 31, 2007 at 08:04 PM

  • Cay, thanks for sharing. Basing on previous discussions on some other forum (but I can't remember which one) I thought that it was not possible to run Java on the OLPC. BTW, regarding the discussion Python vs Java, my point is not much (or not only) about which language is more friendly for children - I mean only a fraction of them will deal with programming, the others being more users for other activities. The lack of Java will prevent them from running some applications (ok, ok, we know that the world isn't filled of _desktop_ Java applications for _end users_).

    A question: what capabilities does the browser have? I mean, is it able to run AJAX and Flash/Flex?

    "I didn't try Netbeans :-)"

    Well, so blueMarine isn't an option, I think ;-)

    Posted by: fabriziogiudici on January 01, 2008 at 09:29 AM

  • If you want to make a case for Java on the OLPC, getting it to run Sugar using jython faster, in a smaller footprint would be the thing to aim for.

    You can always install kaffe or gcj or something like that on it, but you'll suffer from the same problem: there is no inherent need for it on the OLPC, unless you manage to make it run Sugar better than the python VM. Without a real need to have it on the device, it's relegated to the 20M partition for preloaded software by governments, and it'd be hard to fit in a full fledged JRE in there.

    Posted by: robilad on January 01, 2008 at 03:04 PM

  • I, too, got an OLPC.. and gosh is that keyboard meant for people who have tiny fingers. I agree with what I think the point you're making is that one interesting goal for the OpenJDK project would be whatever it takes to get an OpenJDK bundle accepted on OLPC.

    Posted by: robogeek on January 02, 2008 at 12:06 PM

  • We must remember that the XO is designed for 1st graders, so the tiny keyboard is probably a plus... But much to my surprise the XO will detect a USB keyboard if you plug one in.

    -JohnR

    Posted by: johnreynolds on January 03, 2008 at 11:43 AM

  • Here's the OLPC wiki page for Java.

    Posted by: johnreynolds on January 03, 2008 at 12:35 PM

  • This is a very serious question and one that I have thought about many times. So it comes down to the point of an "easy to use" middleware technology versus some very hard to use things for insiders (programmers) and some really dumb to use things for outsiders (end users). Both Linux gearheads and Microsofties in some sense used to say the same thing: We use really complicated software to make very reliable, hard coded, user friendly applications. Java and .NET say -- let's chop the pot. We'll build a really robust half-layer of application with a memory manager and let "web developers" build the rest of it with OOP and "scripty" langugages.

    Posted by: jbailo on January 03, 2008 at 02:47 PM

  • You may find it interesting that I got the Processing and Arduino environments running on the OLPC, both are based on Java. More info on my blog here: http://www.villamil.org/?p=106 Performance is fine. Footprint is small. Running under XFCE, Java applets run fine in the Firefox and Opera browsers. The problem with applets in the Browse activity seems limited only to that.

    Posted by: gpvillamil on March 17, 2008 at 07:43 PM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds