A BBS Example Using Java RMI (J2SE™ 5.0)

Download the following source code for BBS server into directory C:\BBSServer on machine 1:

Compile and run the BBS server on machine 1 as follows:

C:\BBSServer> javac -classpath ./ BBSServer.java
C:\BBSServer> java -classpath ./ BBSServer

Download the following source code for BBS client into directory C:\BBSClient on machine 2:

Compile and run the BBS Client on machine 2 as follows:

C:\BBSClient> javac -classpath ./ BBSClient.java
C:\BBSClient> java -classpath ./ BBSClient <server’s address> hello buddy

Download the same code for BBS client into directory C:\BBSClient on machine 3:

Compile and run the BBS Client on machine 3 as follows:

C:\BBSClient> javac -classpath ./ BBSClient.java
C:\BBSClient> java -classpath ./ BBSClient <server’s address> ni hao

Note: "ni hao" () means "hello buddy" in Chinese.

Run the two clients concurrently and see how the concurrent program works.

Now modify the BBSServer.java file to remove the two keywords "synchronized", re-compile the source code on server and start the BBSServer. Re-run the two clients and see what happens.

Note: J2SE 1.5 adds support for the dynamic generation of stub classes at runtime, obviating the need to use the Java(tm) Remote Method Invocation (Java RMI) stub compiler, rmic, to pregenerate stub classes for remote objects. Note that rmic must still be used to pregenerate stub classes for remote objects that need to support clients running on earlier versions.