RMI Wizard User Guide


RMI Level I

RMI Level II

Introduction

How to Open

How to Start

How It Works

Trouble Shooting

Comments?

RMI Wizard Tutorial

SCJD Study Companion

Introduction

RMI Wizard is designed for new RMI designers to get familiar with the recipe of RMI system. It helps reduce compiling and coding problems which most of programmers suffered when having the first try. It is a good practice to use it to generate a template RMI system and modify the generated code to your needs. Using this Wizard to develop your RMI server for SCJD assignment, you need to recheck the code to make sure thread-safety.

If you have no idea about RMI system, this Wizard will help you learn and understand RMI system quickly. But you are recommended to read RMI Level I tutorial at least to start using RMI Wizard.

If you are not familiar with RMI server with adapter design pattern, you may either learn it from the generated code or read Adapter Design Pattern.

Since this is a learning tool, you cannot use it to design a callback, or set dynamically class loading directly.

Return to top


How to open

When you download the RMITool.jar file, unjar it on the command line:

>jar -xf RMITool.jar
            
To run it on the command line:
>java -jar RMIWizard.jar
            
Download -Under updating now

Return to top


How to Start

A source file named BankAccount is provided with this Wizard for your practice.

To ensure the successful creation, check the prerequisite first:

  1. Assume you have jdk1.2 or jre1.2 above installed.
  2. You must have the local class with a default constructor and have it compiled without error.
  3. The local class should not have any public methods which exist in Object class.
  4. You must put that compiled class at the same directory as this Wizard.
  5. You must know the hostname and port number. You are recommended to use loalhost and default port number first to get familiar with the Wizard.

Steps:

  1. Enter the remote interface name. Any name you give to recognize as a remote object.
  2. Enter a policy file name. A default policy named my.policy has been provided with all permissions.
  3. Enter the class name. You can browse the directory to find the class.
  4. Click the list button on the left side to list all public method signatures in the class. All the methods listed are not editable. They are shown for you to get familiar with the methods in the remote interface. If you don't want some of them to be accessed remotely, modify the generated code, please.
  5. Enter the host name and port number. Use localhost and default port number for the first try.
  6. Click Create button. A working RMI system is created automatically.
  7. You will be informed by a popup window of what are the generated names of your remote interface, remote object, RMI server and RMI client. To avoid name conflicts, all these names are started with Remote_. It is easy for you to recognize, redo and delete.
  8. You will be asked to choose to run it immediately or later. If you are using Win32 system, you can run it immediately. If you choose to run it immediately, a DOS batch file named run.bat will be launched. The created RMI server will start to run. You need to start another DOS command to launch the RMI client via the client.bat to connect to the just created RMI server. (Note: The RMI client created with RMI server is a template which is used to check the RMI server)

    If you use other system instead of Win32, you cannot run it immediately. You have to modify the batch files to suit your scriptings. The order of commands in the DOS batch file is important for successfully running your RMI system.

You can run your server and client at the same directory because the different JVM will be launched for each program. New RMI designers may confuse with it. You can do your assignment in the same way.

NOTES: All of the generated names should be changed to those without "_" underscore to meet Java code convention.

Return to top


How It Works

The RMI Server and client are created based on the data you entered. RMI server is designed with adapter pattern with less code change of your local class and highly flexibility. If you want to add more functionality, just modify the code of the server without alteration of the remote object.

The four files are generated for the RMI system.

  1. The remote interface file -- Remote_yourEnteredInterfaceName.java
  2. The remote object implementation file -- Remote_yourEnteredInterfaceNameImpl.java
  3. The remote server file -- Remote_yourEnteredClassNameServer.java
  4. The remote client file -- Remote_yourEnteredClassNameClient.java

The remote object name is : yourEnteredClassNameObj.

The two batch files are generated for you to try RMI system immediately.

  1. run.bat -- compile all generated code, register remote object, and start remote server
  2. client.bat -- start remote client.

If you want to try your assignment, make a default Data constructor first and generate code and then modify the code to your needs.

For how to make your RMI server thread-safe and how to shut down your server gracefully, see Server Design & Implementation.

Return to top


Trouble Shooting

If you failed to compile the generated files, check the generated files. If the methods you entered are not existing in your local class, the RMI server won't be created.

Use the list button on the left to list the public methods in your class automatically. Check if the public method in the Object class has been listed, if so, it won't compile. Like toString() method, because such method in the super class doesn't throw remote exception.

If you get access denied exception, check the policy file location and name.

Return to top


Comments?

A good comment will be rewarded by having the SCJD Study Companion for free. Please send your comments to GUI with subject "Comments", so your E-mail will get attention quickly.

A new version of RMI Wizard will give you a choice to have auto or manually register the remote object. Dynamically class loading feature will be added in.

Return to top


"Server Design & Implementation" is a part of SCJD Study Companion. It is not available for the RMI tool.

Return to top