First, compile the server program with a JDK 1.1.x compiler,
e.g.:
setenv CLASSPATH /users/dcl0bjc/public_html/Java javac CountServer.javaThis javac command will compile CountIF.java, CountServant.java and CountServer.java to produce the files CountIF.class, CountServant.class and CountServer.class.
At a Unix/MS-DOS prompt, run RMI's rmic command on the file CountServant.class:
rmic RMI.Count.CountServantThis command will create the files: CountServant_Stub.class and CountServant_Skel.class. These files contain the bytecodes of the stub and skeleton.
Now compile the client program:
javac CountClient.java
Before running the server, we need to start the RMI-Registry. We can do this using RMI's rmiregistry command. On Unix, type:
rmiregistry &whereas on Windows 95/NT, type:
start rmiregistry
The server can then be started using a command like:
java -Djava.rmi.server.codebase=http://hercules.dur.ac.uk/~dcl0bjc/Java/ \ RMI.Count.CountServer &This should output:
CountServant: constructor called
Finally, run the client program:
setenv CLASSPATH /users/dcl0bjc/public_html/Java java RMI.Count.CountClient hercules.dur.ac.uk
The client program continually reads in lines from the keyboard. If the line contains the string quit, the client program is terminated; if it contains show, the client program displays the current value of the remote object; otherwise, the client program expects the line to contain an integral value and it instructs the server to set the remote object to this value.