SDSU CS 696 Emerging Technologies: Java Distributed Computing
Spring Semester, 1999
Jini Overview
Previous    Lecture Notes Index        
© 1999, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 21-Jul-99

Contents of Doc 36, Jini Overview

Jini References


Core JINI , Edwards and Joy, Prentice Hall, June 28 1999

JavaSpaces Principles, Patterns and Practice , Freeman, Hupfer, Arnold, Addison-Wesley, June 1999

The Jini Specification , Arnold, Wollrath, O'Sullivan, Scheifler, Waldo, Addison-Wesley, June 1999


Sun’s Jini Web Site:

Jini Community Web Site:

Jini Corner:

Jini API, SDSU Copy:

A Jini Tutorial:

SDSU Jini Course:

Doc 36, Jini Overview Slide # 2

What is Jini?

Released by Sun in January 1999

Jini – a general infrastructure for distributed computing between devices on a network

"Jini technology provides simple mechanisms which enable devices to plug together to form an impromptu community - a community put together without any planning, installation, or human intervention."

Doc 36, Jini Overview Slide # 3
Jini Scenarios

Digital camera and pictures

Camera finds network printer to print pictures
Camera finds network disk drive to save pictures
Camera turns on lights in the room before taking a picture

Palm Pilot

Student uses Palm pilot to select classes and downloads class schedule into Palm pilot calendar

Doc 36, Jini Overview Slide # 4

Jini Services

An entity that can be used by a person, program or another service
Examples of a Service
A computation
Software filter
Hardware device
A user

Doc 36, Jini Overview Slide # 5
Standard Jini Services

Lookup Service
Transaction Manager
JavaSpaces Service

Jini Distribution

Standard services
API for developing Jini clients and servers

Doc 36, Jini Overview Slide # 6

Jini Lookup Service

A Server register a service with lookup service

A Client finds services via the lookup service

Registering a Service

Finding a Service

Interacting with a Service

Doc 36, Jini Overview Slide # 7

Finding a Jini Lookup Service

(Discovery and Join)

There are two ways one can find a Jini lookup service

Each Jini lookup service is bound to a TCP port on a host
Open a connection the correct host and port number for a Jini lookup service

Jini lookup services support IP multicast (
Each lookup service has a list of group names
Clients and servers can do a multicast broadcast for Jini lookup services with:
One or more specific group names, or
The default group name

Doc 36, Jini Overview Slide # 8

Multicast Discovery

The Good

Allows a Jini-aware device to connect to a network without knowledge of the network.

That is there is no need to configure the device to know about the services on the network. Anyone can plug in the device, and it will find the Jini lookup service and know about the available services.

The Bad

Most network administers turn off IP multicast when possible.
This means most networks must be modified to support Jini.

The Ugly

Sun’s Jini PR implies that a Jini system needs no setup.

A Jini system needs at least one lookup service running and multicast to be supported.

Doc 36, Jini Overview Slide # 9

Lookup Service Basics

Server registers with lookup service:

Unique ID
Service attributes
Service proxy code

Client can:

Request a service with a given ID
Request a service that matches one or more attributes
Request a single service or all services that match

Doc 36, Jini Overview Slide # 10

The Service Proxy Code

Proxy is Java code that is downloaded to the client

Client uses proxy code to interact with the service
In the camera-printer example, the print driver would be part of the proxy code downloaded to the camera. This means that a user would not have to load the proper print driver on the camera before using a printer.

Doc 36, Jini Overview Slide # 11
The Service Proxy Code

Proxy can be either:
RMI stub
Uses Java’s RMI protocol to call server methods
Java Serialized object
Can use any protocol to communicate with server
This allows a Jini client to interact with devices that are not Jini aware. A third entity could register for the service and provide the proxy code. The code would have to use the devices native protocol to communicate with the device.

Doc 36, Jini Overview Slide # 12
RMI – Remote Method Invocation

Java’s object version of RPC

Sample Client Code

import java.rmi.*;
public class HelloClient  {
   public static void main(String args[])  {
      Hello remote =
             (Hello) Naming.lookup( "rmi://");
      String message = remote.sayHello();
      System.out.println( message );

Doc 36, Jini Overview Slide # 13

Service Proxy Code and Interfaces

The Jini client needs to know what methods to call to perform a given task – the service interface.

Before writing a Jini client, the service interface must exist

Service Proxy Code and Security

Java 2 (jdk1.2) security model provides fine grain control over:

What code can be downloaded to client?
What system resources the proxy code can access

Jini requires Java 2 for the security model

Doc 36, Jini Overview Slide # 14

Service Proxy Code

The Good

Do not have to manually configure Jini clients with device drivers for each Jini service

RMI generates the proxy code automatically

The Bad

RMI can be slow

RMI can has connection problems on the Internet

Requires http server for distributing class definitions

Downloading class definitions requires programmers to be careful

The Ugly

For consumer products, standard interfaces for the proxy code do not yet exist is has a number of working groups to establish these standard interfaces. If these interfaces are not supported by manufactures of the devices, Jini will not see wide spread use.

Doc 36, Jini Overview Slide # 15


Jini uses leases to keep information about services current

Access to a service is leased for a given duration

If a client wants the service longer, it must request a lease renew before the end of the lease

At the end of a lease, a client’s access to the service is terminated

Lookup Service and Leases

Entries in the lookup service are leased

A device must renew the lease to remain listed in the lookup service

Lookup service leases are for a few minutes

Doc 36, Jini Overview Slide # 16

Hello World Example

This example:
Uses a null lease
Uses unicast discovery & join
Is derived from an example in Noel Enete’s Nuggets for Jini

The Interface

package whitney.jini.examples.hello;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface HelloInterface extends Remote 
   public String sayHello() throws RemoteException;

Doc 36, Jini Overview Slide # 17
HelloServer Implementation
package whitney.jini.examples.hello;
import net.jini.core.entry.Entry;
import net.jini.core.lookup.ServiceID;
import net.jini.lookup.entry.Name;
import com.sun.jini.lookup.ServiceIDListener;
import com.sun.jini.lookup.JoinManager;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;
public class HelloServer extends UnicastRemoteObject 
   implements HelloInterface, ServiceIDListener
   private ServiceID myID;
   public HelloServer() throws RemoteException 
      {      }
   public String sayHello () throws RemoteException
      return ("Hello World from Jini!");
   public void serviceIDNotify (ServiceID uniqueID)
      myID = uniqueID;
      System.out.println("server: ID set: " + myID );

Doc 36, Jini Overview Slide # 18
Registering HelloServer with Lookup Service

   public static void main (String[] args) throws Exception
      System.setSecurityManager (new RMISecurityManager ());
      HelloServer myServer = new HelloServer ();
      Entry[] identityingAttributes = new Entry[1];
      identityingAttributes[0] = new Name("HelloServer");
      JoinManager myManager = new JoinManager 
            new LeaseRenewalManager ()
      System.out.println ("Server has joined a lookup service!");

Doc 36, Jini Overview Slide # 19
HelloClientUsing the HelloServer – Unicast Discovery

package whitney.jini.examples.hello;
import net.jini.core.entry.Entry;
import net.jini.core.lookup.ServiceTemplate; 
import net.jini.core.lookup.ServiceRegistrar; 
import net.jini.core.discovery.LookupLocator;
import net.jini.lookup.entry.Name; 
import java.rmi.RMISecurityManager;
public class HelloClient
   public static void main (String[] args) throws Exception
      System.setSecurityManager (new RMISecurityManager ());
      LookupLocator lookup = new LookupLocator ("jini://");
      ServiceRegistrar registrar = lookup.getRegistrar ();
      Entry[] serverAttributes = new Entry[1];
      serverAttributes[0] = new Name ("HelloServer");
      ServiceTemplate template = 
         new ServiceTemplate (null, null, serverAttributes);
      HelloInterface myServerInterface = 
         (HelloInterface) registrar.lookup (template);
      System.out.println ( myServerInterface.sayHello () );

Doc 36, Jini Overview Slide # 20
HelloClient Multicast Discovery

package whitney.jini.examples.discoveryJoin;
import java.rmi.RMISecurityManager;
import net.jini.core.discovery.LookupLocator;
import net.jini.core.entry.Entry;
import net.jini.core.lookup.ServiceRegistrar; 
import net.jini.core.lookup.ServiceTemplate; 
import net.jini.discovery.DiscoveryEvent;
import net.jini.discovery.DiscoveryListener;
import net.jini.discovery.LookupDiscovery;
import net.jini.lookup.entry.Name; 
import sdsu.util.ProgramProperties;
public class HelloClient  implements DiscoveryListener {
   public static void main (String[] args) throws Exception {
      System.setSecurityManager (new RMISecurityManager ());
      ProgramProperties flags = new ProgramProperties( args);
      if ( !flags.containsKey(  "group") ) {
         System.out.println( "Usage: java HelloClient -group=groupName" );
      String groupsString = flags.getString( "group" );
      new HelloClient( groupsString );
      // discovery nneds some time to work
      Thread.currentThread().sleep( 1000 * 15 );
   public HelloClient( String group ) throws IOException {
      String[] serverGroup = { group };
      LookupDiscovery findAllLookupServices = 
         new LookupDiscovery( serverGroup );
      findAllLookupServices.addDiscoveryListener( this );
   public void discovered(DiscoveryEvent lookupService ) {
      findServer( lookupService);
   public void discarded(DiscoveryEvent lookupService) { // don’t care about this}

Doc 36, Jini Overview Slide # 21
HelloClient Multicast Discovery

   private void findServer( DiscoveryEvent event)  {
      Entry[] serverAttributes = new Entry[1];
      serverAttributes[0] = new Name ("HelloServer");
      ServiceTemplate template = new ServiceTemplate (null, null, serverAttributes);
      try  {
         ServiceRegistrar lookupServices[] = event.getRegistrars();
         for (int k = 0; k < lookupServices.length; k++) {
            HelloInterface myServerInterface = 
                  (HelloInterface) lookupServices[k].lookup (template);
            if (myServerInterface != null ){
               System.out.println ( myServerInterface.sayHello () );
            } else{
               System.out.println ( "No server yet" );
      } catch (Exception lookupProblem)  {

Doc 36, Jini Overview Slide # 22
Transaction Manager

Uses a two-phase commit protocol to provide ACID transactions

All operations in the transactions must occur or none of them can occur
Completion of a transaction must leave the system in a consistent state
Transactions must not affect each other
The results of the transaction should be as persistent as the entities partaking in the transaction

Transaction manager provides the framework to perform ACID transactions

Objects in the transaction are responsible for insuring the ACID properties are carried out.

Transaction protocol is very general to allow for a wide range of applications

Doc 36, Jini Overview Slide # 23
Other Jini Topics

Shares data between separate parts of distributed program

Remote Events
Allows Jini devices to be notified of events on remote machines

Insures services remain active
Restarts services when needed

Doc 36, Jini Overview Slide # 24

Future of Jini

Work in progress

Need standard interfaces for common devices
Need manufactures to build in Jini support


Microsoft’s Universal Plug & Play

Copyright ©, All rights reserved.
1999 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA.
OpenContent license defines the copyright on this document.

Previous    visitors since 21-Jul-99