CISC 370 Lecture Notes for Class No. 23 May 2, 2000

Course Home Prev Lect Next Lect Example Progs Exercise Solns
CoreJava Progs
Documentation
Gen'l Docs Java 2 APIs Java Glossary Term Proj Info

Assignment

Reading:
Horstmann & Cornell,
Exercises:

None

Today's Lecture Topics

  1. Review of steps for preparing code for RMI uses

  2. Review of steps for compiling the code and creating the stubs with the RMI compiler, rmic -v1.2

  3. Running an RMI application w both server and client on the same machine and all the code in a single directory. This is the simplest way to start a use of RMI and is recommended for initial testing. In this case, we just (1) go to the directory that contains all the code along with the client.policy file, (2) start the RMI registry as a background process with the instruction rmiregistry 13772 & (use your own user number instead of 13772), (3) start the server code by doing java ProductServer & , and (4) run the client by executing the command java -Djava.security.policy=client.policy ProductClient

    Important: kill all processes running in the background, especially the rmiregistry.

  4. Running an RMI application w both server and client on the same machine but with the server and client class files in separate directories and the code that must be downloaded by the client (that is, the Stub and interface classes) on the web server udel.edu.

    1. Create the server directory and put these files in it
            ProductServer.class
            ProductImpl.class
            Product.class
            ProductImpl_Stub.class
           
      Create the download directory as a subdirectory of your public_html directory on the web server udel.edu and put the following files in it.
            ProductImpl_Stub.class
            Product.class
           
      Create the client directory and put the following files in it.
            ProductClient.class
            Product.class
            client.policy
           
      The client.policy file should contain
      grant
      {  permission java.net.SocketPermission
            "*:1024-65535", "connect,accept";
         permission java.net.SocketPermission
            "udel.edu:80", "connect";
      };
           

    2. Now start the rmi registry. Due to its flakiness, it important to start it in a directory that contains no class files and to have the CLASSPATH unset. This can be done by a set of Unix commands similar to the following:
            tcsh				// Start a new shell
            cd				// change to your top level directory
            ls *.class			// Verify that there are no .class files
            unsetenv CLASSPATH		// To unset the CLASSPATH
            rmiregistry 13772 &		// To start registry in background
           
    3. Start the rmi server by issuing the following Unix commands
            tcsh				// To start a new shell
            cd server				// Change to the server directory
            java -classpath .  -Djava.rmi.server.codebase="udel.edu/~caviness/download/" ProductServer &
           
    4. Start the rmi client by issusing the following Unix commands
            cd client				// Change to client directory
            java -classpath . -Djava.security.policy=client.policy ProductClient
           

  5. Deploying the client and server on separate machines.

Back to the CISC 370 homepage.

This page has been accessed times since 1 May 2000.

Corrections, suggestions and comments to Bob Caviness

Copyright 2000 B. F. Caviness