Tutorials

Jini Example
Jxta Example
Web Services

Related

Jxta
Jini
Web Services

For More Info

From P2P to Web Services and Grids: Peers in a Client/Server World
Ian J. Taylor, 2004
Publisher: Springer
ISBN: 1-85233-869-5

Jini Tutorial

This is a simple Jini example that does a 'Hello World' type call on a remote machine using Jini. It consists of three files:

  1. MyServiceInterface.java: This is the Java Jini proxy object (that the client calls locally) to the remote implementation of this code.
  2. MyService.java: This is the remote implementation of the Java proxy (MyServiceInterface) that is run on the remote machine
  3. MyClient.java: This is the local client that calls the Java proxy (MyServiceInterface) that transmits this call over the network to call the function in the remote object (MyService).

Batch Files

This example is configured to run the client and the server on ONE machine. Although this is not distributed in the network sense the principles are exactly the same. You are welcome to reconfigure the code to insert an IP address of a remote machine if you want to run this across the network.

  • compile.bat: compiles the example and creates the local stubs file needed.
  • Setup.bat: Sets up the environment. You MUST edit this file to configure your platform i.e. must insert the location of the Java runtime library (as follows).

This is the setup.bat file on my local machine:

set RUNTIME_JAR=c:\java\jdk1.4\jre\lib\rt.jar
set JINIHOME=.
set JINI_CLASSPATH=.;%RUNTIME_JAR%;%JINIHOME%\lib\jini-core.jar;
%JINIHOME%\lib\jini-ext.jar;%JINIHOME%\lib\reggie.jar;
%JINIHOME%\lib\reggie-dl.jar;%JINIHOME%\lib\tools.jar

Therefore replace the RUNTIME_JAR file with the path of your JVM.

Running the Jini Services:

You must run 3 batch files BEFORE (in order) you run the actual java core. These are:

  • HTTP-1.bat: You must run this first on the remote machine. It is the HTTP server for the transportation of the Java code on the Jini network
  • RMID-2.bat: This is the RMI registry that keeps track of the RMI objects that are currently available on the remote machine.
  • REGGIE-3.bat: This is a Jini lookup server.

Running The Java Code

  • runService.bat: This is a batch file that uses the policy.all file to set up the security model (all permissions granted in this example) and runs the RMI Service, RemoteMessage.
  • runClient.bat: Again, uses the policy.all file to set up the security model and runs the RMI client, LocaLObject.