Java Reference
In-Depth Information
The source code listed earlier and appearing on the Web Course includes some
diagnostic output written to System.err ,soone should see the following
appearing in the console window in which the command is issued:
Constructing an RMIExampleImpl
(re)binding it
RMIExampleServer ready and waiting on clients
18.6.6 Run the client
The registry and server are now both running, so we can finally test the client
application. The command line for the client needs the following three items -
the CLASSPATH , the policy file, and the client class name. As explained earlier,
the client.policy file is
grant {
permission java.net.SocketPermission " localhost " , " connect,
resolve " ;
permission java.io.FilePermission
" c: \\ javatech-18 \\ build \\ classes \\ - " , " read " ;
}
Another console window is required in order to launch the client since the previous
console window is occupied running the server. The command line to launch the
client is
java -classpath client.jar
-Djava.security.policy = client.policy
javatech.rmi18.client.RMIExampleClient
The expected output in the client console window is
RMIExampleClient: looking up server //localhost:3001/rmi-
example-server
RMIExampleClient: found it!
Calling remote method1 which should echo the string ' hello
from client '
According to the remote add(), the sum of 18 and 34 is 52
Meanwhile, the following two lines should be added to the output in the server
console window:
RMIExampleImpl.method1: hello from client
RMIExampleImpl.add: computing sum of 18 and 34
Search WWH ::




Custom Search