Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
 

RMI Client Callbacks


by jGuru

[Exercise | API Docs | Short Course| Exercises]

Help is available for each task.



    Task 1

    Define and compile the TimeMonitor interface.


    Create the interface TimeMonitor, which has one method. The method is called tellMeTheTime. It accepts one parameter of type Date and returns void.

    Remember that remote interfaces must extend java.rmi.Remote and the all remote methods can throw java.rmi.RemoteException.

    Compile the file with the command:

    javac TimeMonitor.java

    Task 2

    Define and compile the TimeServer interface.


    Create the interface TimeServer, which has one method. The method is called registerTimeMonitor. It accepts one parameter of type TimeMonitor and returns void.

    Remember that remote interfaces must extend java.rmi.Remote and the all remote methods can throw java.rmi.RemoteException.

    Compile the file with the command:

    javac TimerServer.java

    Task 3

    Complete the implementation for the method registerTimeMonitor in RMIServer.


    The class RMIServer implements the TimeServer interface. You will need to complete the implementation of registerTimeMonitor in RMIServer. Refer to the comments in the code file for guidance.

    Task 4

    Complete the definition of the class TimeTicker.


    The class TimeTicker is defined inside the file for RMIServer. You will need to complete the implementation of this class by adding a call to the tellMeTheTime method of the TimeMonitor interface. This is the call that performs the callback to the Applet.

    Task 5

    Compile the server, RMIServer and create the stub and skeleton files.


    Use the javac utility to compile the RMIServer file.

    javac RMIServer

    Use the rmic utility with RMIServer.

    rmic RMIServer

    Notice that RMIServer implements the exported service. Because RMIServer extends RMIServer it cannot also extend UnicastRemoteObject. Instead, RMIServer must make an explicit call to UnicastRemoteObject.exportObject before it can register itself with the Registry. This call is normally made automatically in the constructor of UnicastRemoteObject.

    Task 6

    Prepare the Applet for execution.


    The Applet code has been completed for you. You should examine it to see how it implements the TimeMonitor interface and prepares itself for use by RMI with a call to UnicastRemoteObject.exportObject.

    First you must compile it with the following command:

    javac Applet1.java

    Next, create the stub and skeleton files with the rmic utility:

    rmic Applet1

    Task 7

    Start the RMI Server in its own DOS console.


    Run the class RMIServer with the java utility.

    java RMIServer

    Task 8

    Start the Applet with the appletviewer.


    Use the program appletviewer and execute the Applet.html file. This HTML file contains the commands to run Applet1.class.

    appletviewer Applet.html

Copyright 1996-2000 jGuru.com. All Rights Reserved.


[ This page was updated: 23-Feb-2000 ]
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.