How to Start an RMI Example
- Make a directory where you want this stuff
mkdir /home/fred/rmi
- CD into that directory
cd /home/fred/RMI
- Copy the date example into the directory
cp /home/rappleto/pub/Classes/RMI/DateExample/*.java .
Or get it at http://euclid.nmu.edu/~randy/Classes/RMI/DateExample
You need the *.java files and the policy.txt file.
- Edit the client and server to use a unque port
java.rmi.Naming.rebind("rmi://euclid.nmu.edu:1099/count",v);
s=(RemoteInterface))java.rmi.Naming.lookup("rmi://euclid.nmu.edu:1099/count");
- Compile the remote object. Note that you do not
name the file, but the class (don't say blah.java, just blah). This should create a
*Stub* file.
javac RemoteObject.java
rmic RemoteObject (Only for very old systems)
- Compile the client and the server
javac Client.java
javac Server.java
- Maybe
start the RMI registry on a unique port number. You should
start it if is's not already running, and your server program doesn't
start it automatically. I use
1099. You pick your own. The code I give you starts on, so this is unneccesary.
rmiregistry 1099 &
- Start the server
java -Djava.security.policy=policy.txt Server &
- Start the client
java -Djava.security.policy=policy.txt Client
And it should work!