Articles Weblogs Books School Short Cuts Podcasts  

Learning the JXTA Shell
Pages: 1, 2, 3, 4, 5

Can we talk?

While the example above provided some insight into message passing via pipes under JXTA, the shell does actually have some rudimentary instant-messaging functionality. More a piping demonstration than anything else, talk resembles the *nix write functionality, with each peer establishing its own talk connection to the other.

JXTA>talk -register pooh
User : pooh is now registered
JXTA>talk -login pooh
JXTA>talk piglet
talk: piglet is not a registered user
JXTA>Shell -s

Pooh registers a talk user (read: talk advertisement) "pooh" and logs in (read: starts a listener daemon). He tries to find Piglet, who has not yet registered as a talk user. We use Shell -s to create a new shell for Piglet.

Table of Contents

Old Favorites
Getting to know me
Peer Groups
P2P Piping
Can we talk?

JXTA>talk -register piglet
User : piglet is now registered
JXTA>talk -login piglet

Piglet creates a talk user "piglet" and logs in.

JXTA>talk piglet
found user's advertisement attempting to connect
talk is connected to user piglet
Type your message. To exit, type "." at begining of line
Hello, Piglet!

Pooh tries again, this time successful in finding Piglet and sending him a greeting.

JXTA>talk: from jxta://59616261646162614A787461503250333DA927976125
000000000000301 to piglet
Message: Hello, Piglet!

JXTA>talk -u piglet pooh
found user's advertisement attempting to connect
talk is connected to user pooh
Type your message. To exit, type "." at begining of line
And a hello to you too, Pooh.

Piglet receives Pooh's message -- albeit in rather ugly form. Now, Piglet can't simply reply to Pooh, as talk is a one-way piped message. So Piglet establishes his own talk session to Pooh. You'll notice the slightly different form of talk -u piglet pooh, resulting in a much cleaner message with proper attribution in Pooh's shell.

JXTA>talk piglet
found user's advertisement attempting to connect
talk is connected to user piglet
Type your message. To exit, type "." at begining of line
Hello, Piglet!

talk: from piglet to pooh
Message: And a hello to you too, Pooh.

JXTA>talk -logout pooh
JXTA>talk: stop listening for user :pooh

Once our friends are ready to conclude their chat, each enters a period on a line by itself and optionally logs out. Note that talk advertisements created by talk -register hang around between shell sessions; before one can chat, however, one must talk -login to start a new listener.

Incidently, as I mentioned a moment ago, a talk registration is simply a JXTA advertisement stored in a local environment variable. We can take a closer look using our old friends, env and cat.

stdout = Default OutputPipe (class
stdin = Default InputPipe (class
adv0 = local jxta advertisement (class net.jxta.impl.protocol.PipeAdv)
stdgroup = Default Group (class net.jxta.impl.peergroup.StdPeerGroup)

JXTA>cat adv0
<?xml version="1.0"?>

<!DOCTYPE jxta:PipeAdvertisement>


Hardly user-friendly in its shell implemention, such talk functionality has already been implemented in InstantP2P, a Java AWT-based GUI chat/file-sharing demonstration application.


To log out of the JXTA shell, type exit at the prompt or just close the shell window. Quite a bit of information is retained between shell sessions including settings, cached peers, groups and other advertisements. To clear your peer or group caches, use the -f option mentioned earlier. To start from scratch, delete the following files/directories: PlatformConfig, PlatformPeerGroup, jxtaConfig, and cm.


Bear in mind that the JXTA shell is only for demonstration and debugging purposes and should not be relied upon to be absolutely stable or emulate a full shell. At the time of this writing, there are a few gotchas and bugs:

  • As mentioned above, Windows 2000 users may need to skip the installer and download the latest nightly build ZIP file.
  • Sometimes launching the shell does absolutely nothing. Windows (espectially Windows 2000) users may need to log out and back in, or even reboot.
  • Shells spawned via Shell -s are not truly independent. Closing or exiting from the primary shell closes the entire application and all windows.
  • Ctrl commands behave very much as Windows GUI users expect, and completely confounds those more at home on the DOS or *nix command-line. ^C isn't interrupt and ^Z isn't suspend; the former copies selected text and the latter does nothing at all. See
  • Talk is currently extremely slow when not simply talking to yourself from one shell window to another.

Where to go for more...

Disclosure: The author has been a member of the JXTA's Technical Advisory Committee during its pre-launch development.