Today, we will focus on how to use codebase. We will continue with example " Product " from last RMI lab.

 

Before run the RMI programs, we have to make some changes in the files:

1.Edit ProductClient.java

In this file, make changes : String url="rmi://arabica.labunix.uqam.ca:xxxx/";

You can give xxxx any port number between 1024 to 65535. for example: 7777

Remember to compile it after changes.

2.Edit ProductServer.java

In this file, make changes:

Naming.rebind("rmi://arabica.labunix.uqam.ca:xxxx/toaster",p1);

Naming.rebind("rmi://arabica.labunix.uqam.ca:xxxx/microwave",p2);

Remember to compile it after changes.

3. Edit client.policy

In this file, add:

~~~~~~~~~~~~~~~~~~~~~~~~~~~

permission java.net.SocketPermission

"*:80","connect";

~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now deploying the program-->>

Please follow below steps:

The client directory contains the files that are needed to start the client.

Save following files on your client directory.

ProductClient.class

Product.class

client.policy

ProductServer.class

ProductImpl.class

Product.class

ProductImpl_Stub.class

**Don't forget to put the stub class files into the server directory.

ProductImpl_Stub.class

Product.class

Run command: rmiregistry xxxx &

**Be sure that: the directory where you run rmiregistry, the CLASSPATH was unset, and also free from class files.

Under directory server, run command:

java -Djava.rmi.server.codebase=http://arabica.labunix.uqma.ca/~exxxxxx/download/ ProductServer

exxxxxx is your unix account ID, for example e333444.

**Don't forget codebase URL end in a slash.

go to client directory.

run command:

java -Djava.security.policy=client.policy ProductClient

 

The program simply prints

I am a Blackwell Toaster. Buy me!

I am a ZapXpress Microwave Oven. Buy me!