Home : Course Map : Chapter 18 :
RMI Example Support Files
JavaTech
Course Map
Chapter 18

Introduction
Server Demo
Client Demo
Demo Support
Resources
Exercises

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

The support files are in the directory src, which lies directly above javatech.

javatech-18
  |
  |__ src
        |
        |__ javatech
              |
              |__ rmi18
                    |
                    |__ client
                    |
                    |__ server
                          |
                          |__ impl

 

The support files include the security policy files for the client and server, the command files (for a Windows platform) and a readme to give instructions to the user.

These policy files determine the security settings for the client and server programs:

client.policy

grant {
  permission java.net.SocketPermission "localhost", "connect, resolve";
  permission java.io.FilePermission ...no break... "c:\\JavaTechBook\\Code\\P2\\Chapter18\\javatech-18\\build\\classes\\-", "read";
  /* This also works, but is a bit of overkill
  permission java.io.FilePermission "<>", "read";
  */
};

local-server.policy
/* Server permissions required for the rmi18 server when client and server
   are running on the same host */

grant {
  permission java.net.SocketPermission "localhost", "accept, connect, resolve";
};

 

The following files assist the user with building and running the client and server programs on a MSWindows platform. To fit within the table here, in some places the command lines are broken where indicated. In the actual files there are no line breaks.

build.bat

@rem Builds the RMI example from Chapter 18.

@rem Set up some local environment variables
setlocal
set class_dir=build/classes
set ifc_dir=src/javatech/rmi18/server
set impl_dir=src/javatech/rmi18/server/impl
set client_dir=src/javatech/rmi18/client

@rem Create the build and classes directories
mkdir build
mkdir build\classes

@rem Compile everything
javac -classpath %class_dir% -d %class_dir% %ifc_dir%/*.java
javac -classpath %class_dir% -d %class_dir% %impl_dir%/*.java
javac -classpath %class_dir% -d %class_dir% %client_dir%/*.java

@rem Run the rmic compiler to generate stubs and skeletons for RMIExampleImpl
rmic -classpath %class_dir% -d %class_dir% javatech.rmi18.server.impl.RMIExampleImpl

@rem Create a client-only jar file from which to run the client.
@rem cd to the top of the classes directory
cd build\classes
@rem jar the needed files with the proper directory structure
jar cf client.jar javatech/rmi18/server/RMIExampleInterface.class javatech/rmi18/client/RMIExampleClient.class
@rem move the new jar file up to the root directory
move client.jar ..\..
@rem and cd back to the root directory
cd ..\..
endlocal

clean.bat
@rem Clean up the build directory by deleting it.
rmdir/s/q build

@rem Clean up all jar files
if exist client.jar del/q client.jar
client.bat
@rem Run the RMIExampleClient from chapter 18.
java -classpath client.jar -Djava.security.policy=client.policy ...no break... javatech.rmi18.client.RMIExampleClient
server.bat
@rem Run the RMIExampleServer server from chapter 18.

@rem start the rmiregistry using port 3001
start rmiregistry 3001

@rem run the server code
java -classpath build/classes -Djava.rmi.server.codebase=file:///c:/JavaTechBook/Code/P2/Chapter18/javatech-...no break...18/build/classes/ -Djava.security.policy=local-server.policy ...no break... javatech.rmi18.server.impl.RMIExampleServer

 

 

Most recent update: Oct. 13, 2005

  
  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.