Ring fever: A first-hand look at Java-powered jewelry

JavaWorld columnist and former JavaSoft engineer Chuck McManis gets a serious case of technology fever

JavaOne: A lot of hype, not a lot of technical details. That was my impression of the four days following the third-year anniversary of Java's Internet debut for public consumption (March 23, 1995). And yet, one thing stood out at the conference and captured my imagination: The Ring. Not just any ring, mind you. No, this was the Java Ring, and unlike the umpteen million bulky class rings from forgotten alma maters that it might resemble, the Java Ring ring is special. It runs Java code. Yup, read that again: It runs Java code.

The mind whirls and disbelief sets in. "You mean it stores code that can be run by another program, right?" No, I mean it actually executes its own form of Java bytecode, right there on the ring. I'll pause for a moment and let that sink in...

OK, welcome back. Yes, it's a nerd's holiest-of-holy toys. It's a secret decoder ring that actually decodes. And then the second bombshell hits: It does world-class encryption. Not that letter-substitution stuff that the ring you got out of yesterday's Cheerios box did. It can do 1024-bit RSA public key encryption. Whoa, the head spins. (No, not like the infamous spinning-heads applet. I feel the spinning.)

A sordid tale of sleepless nights (in four acts)

Day 1: The beginning

I live in the "south bay," that part of the San Francisco Bay Area that really isn't on the peninsula but still wants to seem more upscale than San Jose. We call it the south bay, and its only 45 miles or so from the Moscone Center, the site of JavaOne. Of course, most tourists tend to think San Francisco is the Bay Area -- but Silicon Valley is the true heart of the Bay Area, and north of here is the City.

Java Ring with ring reader

What that means for me is that JavaOne is close enough that I can't get my company to put me up in a hotel, and far enough that it takes some planning to get there on time. For that, we've got the Caltrain. A commuter rail service that runs up through the southern part of the Bay Area to a train station that's just far enough away from the Moscone Center to make for an annoying walk or an overpriced cab ride. I walked on Tuesday morning and got to Moscone on time, only to realize that the line out the door was for pre-registered folks such as myself: So much for making the beginning of the keynote speech. So I stand in line, get my badge and finally rush into the "overflow" room to watch the keynote on TV. Now, I don't know about you, but I'm not a big fan of paying ,200 to go to a conference just to watch the keynote address on TV. All the same, halfway through James Gosling's talk (voted Best Keynote by yours truly), he asked who among the audience had their ring.

"What ring?" I said.

"The one that runs Java," said James.

Well, out the door in a flash, and back to the materials center. "Have you heard about the ring?!?" I present my badge and ticket and voilĂ !, I'm looking at my new Java Ring. Back to the big TV room just in time to catch James explaining how the ring can hold your business card information and we'll all soon be running the Fractal game on it.

Now my curiosity is really piqued and I can't find out any more about this thing, so after the first technical session I'm off to the Java Pavilion (read: hype bazaar). And there, in an innocuous-looking booth, is Dallas Semiconductor, and -- lo and behold! -- its reps are selling something that looks like it goes with the Java Ring. They are! It's the reader and adapter for your computer. Only 5. So I plunk down the plastic and walk out with a Blue Dot reader. Nearly beside myself with excitement, I find that you can download the demo code from http://www.ibutton.com. Which, when I get home that night (after the Java Pavilion cocktail party), I promptly attempt.

Of course, if life were fair I'd be done, but it isn't, and I wasn't. The Web site had been misconfigured; my browser assumed the tarred and gzipped file was text, and downloading it resulted in el-junko. Sigh. I remembered, however, that the machines in the Hackers' Lab had ring readers, and the next morning I resolved to set about finding out how they worked.

Day 2: To ask permission is to seek denial

It's Wednesday morning. I listen half-heartedly to the keynote address (the Ed-and-Scott show); Zander and McNealy are remarkably composed given the injunction handed down the day before. (See the JavaWorld news article, "Sun's Scott McNealy and Alan Baratz discuss preliminary ruling in MS/Sun suit," referenced in the Resources section below.) As soon as the talk is over I go out to the Hackers' Lab and start exploring one of the machines. Sure enough, there's a file called jibkit07.tar on the machine, and therein I find a bunch of Java source code related to the Java Ring (conveniently located in a directory called javaring).

Exploring further, I found the source to the BusinessCard applet and the Fractal applet. Unfortunately, whenever I plugged my ring into the button, a bogus applet came up with only the show choices. Hmmm, not good. So (like any good hacker) I used the copy of Netscape that was running on the box and mailed the .tar file to my home machine. So much for the download problem.

I then trekked across the pavilion to catch the tail-end of the talk Dallas Semiconductor was giving about the ring. I was too late to catch the whole thing, but good info nonetheless.

Wednesday evening was the JavaWorld party. Quite fun, and I was glad to meet many readers and some of the other authors I knew of only by name, and my editor, Jill Steinberg, whom I'd never met face to face. But on my mind was the ring, always the ring.

At home, around midnight, I fired up my development environment and started hacking. I immediately ran into problems, however. Suspecting my JDK 1.1.2 release, I started downloading the 1.1.5 release over a 33-kilobit per second modem -- ugh! About 15 minutes into the download I remembered that all JavaOne attendees were given the Java Developer CD at the show, so I dug it out. There was the 1.1.5 JDK. Whoo-hoo! Back in business.

I struggled unsuccessfully for another hour and a half trying various things to get my Java Ring to respond to the apduGUI program in the Toolkit. No joy. Couldn't even get it to start. My classpath was full of so many jar files it couldn't be typed in the DOS command line. Then a typo got the apduGUI program to come up. It turns out the Developer Kit has an extra copy of java.lang.Object in it, whoops. After fixing that I got the programs to come up, but they still wouldn't talk to my ring. I resigned in disgust at about 3:30 a.m. Up at 6:00 a.m. for day three.

Day 3: He went thatta way!

Day three started a bit slowly. I actually woke up at 6:00 a.m., turned off my alarm and then got out of bed around 9:00 a.m. So much for the panel of experts on the future of Java. That was OK; I arrived in time to attend JavaWorld columnist and Sun engineer Rinaldo Di Giorgio's talk on smart cards. That was helpful and explained what some of the terms -- such as APDU -- I'd been reading about in the ring docs meant. Armed with new knowledge, I went hunting for a Dallas Semiconductor application engineer.

These guys turned out to be harder to find than I would have expected. I finally tracked one down in the Hackers' Lab and talked to him about my lack of success so far. Once we got down to specifics, we discovered I had hooked my ring to COM3, but the library only knows about COM1 and COM2. For those of you who don't have Windows-based computers, these are serial ports. For those of you who work at Sun, the answer to your next question is, Yes, you can have up to four serial ports.

This points out something rather annoying: Sun doesn't know all that much about Wintel machines. Now, it wouldn't be so bad for Sun to claim ignorance on this topic, but JavaSoft is supposed to be a cross-platform company, supporting everything from jewelry to supercomputers. Guess it will just have to fill in a few gaps.

Thursday night, of course, was the big JavaOne party, dubbed "Retro & Beyond." Given that somebody made 0-million on JavaOne, the party sucked. For what I was paying, I would have expected to see the Starship playing on the Retro side of the house while Nine Inch Nails blasted through the Beyond side. No such luck. At least the conversation was good, and the video games on the Retro side were fun as well. More ring discussions were pursued, and by the time I got home, just after midnight, I had a couple more tricks to try.

I moved my Blue Dot reader over to COM2 and downloaded the freshly released java.comm package from the Java Developer Connection Web site. I wrote the following simple class:

import javax.comm.*;
import java.util.*;
import java.io.*;
public class test {
   public static void main(String args[]) {
    CommPort te = null;
    for (Enumeration e = CommPortIdentifier.getPortIdentifiers(); e.hasMoreElements(); ) {
        CommPortIdentifier cp = (CommPortIdentifier) e.nextElement();
        if (cp.getName().compareTo("COM2") == 0) {
            try {
            te = cp.openPort("Test", 500);
            } catch (Exception ee) { 
                System.out.println("Port in use, sorry.\n");
                te = null;
            }
        }
        System.out.println("Available port : "+cp.getName());
    }
    if (te != null) {
        OutputStream os;
        try {
            os = te.getOutputStream();
        } catch (Exception e3) { os = null; }
        if (os == null) {
            te.closePort();
            System.exit(1);
        }
        PrintStream ps = new PrintStream(os);
        for (int i = 0; i < 10; i++) {
            ps.println("This is a test "+i);
        }
        te.closePort();
    }
   }
}

And it confirmed my fears: The Java communications framework knows only about LPT1, COM1, and COM2 on Win95 machines. Ouch. I still couldn't get the test program apduGUI to work, and I was getting desperate. I decided to try one of the others. As chance would have it, I tried the BusinessCard demo by starting up the BusinessCardDisplay class that was part of the Examples directory.

After much gnashing of teeth (and messages about timeouts and searching for drivers), I got the BusinessCard display up, and -- lo and behold! -- it found my ring and displayed my data! Success! If it weren't two in the morning I might have jumped for joy. As it was, my elation was somewhat muted. I set about fixing my card such that my coffee preference was listed as Dr. Pepper -- I don't drink coffee. I hacked the BusinessCardDisplay applet and "fixed" it such that I could store my preferences in the ring. Then off to bed.

Day 4: Disaster and redemption

I woke on day four bleary-eyed and perhaps a bit hung-over. Partying, hacking, and not sleeping are not conducive to clear thinking. I did manage, however, to struggle out of bed and get to the conference. The crowd was significantly reduced, and I checked right away to see if I could show off my new "coffee preference" on the JavaStations at the show. It worked great, much to the annoyance of the folks running the coffee shop demo. (They were taking orders by having us put our rings in their reader; then they would serve your preferred coffee. Of course, my ring ordered Dr. Pepper. Lots of laughs.)

By now the folks running the TV/set-top box thingies with Blue Dot readers had them up and running. I thought it would be neat to show off my ring modifications. Unfortunately, I hadn't bothered to check out the interface first; in fumbling around got to the back end of the personalize-your-ring page, my ring was "personalized" with the previous user's information. Yuck! Now, not only did my ring not contain my kewl new beverage preference, it didn't even look like it belonged to me!

The guys at the TVs were no help at all, so I went looking for a Dallas Semiconductor engineer. No joy there -- they were all headed to Dallas (or wherever they go when they aren't at the Moscone Center). Then I found out that the Java Lobby guys had out-hacked me. They were using the BusinessCard applet to not only modify attendee's rings, but to register folks for the Java Lobby. I took the opportunity to reprogram my ring. Of course, they hadn't added the preference hack, so I was able to reclaim my personal information, but not my Dr. Pepper preference.

JavaOne slowly wound down. I ended up getting a jewelry-style ring (one that would fit my plump digit) and went home for some much-needed sleep.

Epilogue

There is no moral to this story, except perhaps that if you don't sleep you may catch a cold (I did). Over the weekend I was able to delve deeper into the code that runs the ring. Some useful resources are the JavaCard documents on the java.sun.com Web site, and of course the two articles in this issue of JavaWorld (April 1998). And, for those of you who are electron-pushers like myself, the Dallas Semiconductor application note on the serial interface (App74) is quite interesting as well. (See the Resources section below for links to these useful resources.)

I've started playing with the crypto code and hope to have a real secret coder ring running by the time you read this. The current ring has 6 kilobytes of RAM; Dallas Semiconductor claims it could do more than 128 kilobytes in the same package. That's the ring I'd really like to see.

1 2 Page
Join the discussion
Be the first to comment on this article. Our Commenting Policies
See more