Java Reference
In-Depth Information
Example 5.13 A Java security policy file suitable for the RMI example
grant {
permission java.net.SocketPermission "*:1024-65535", "connect,accept";
permission java.net.SocketPermission "*:80", "connect,accept";
};
5.8.4.2
We have two machines. One, penfold , is our server machine. The other,
grovel , is our client machine. To keep things straight in our samples, the shell
prompts will have the host names in them.
If you are using a JDK that supports the 1.2 RMI specification (and we
hope you are—it's in all current JDKs), you have to give your server and your
client permission to access the network ports needed to run. By default, the
Java runtime will look for a security policy file in the home directory of the
user running the VM. The default name of the file is .java.policy . Exam-
ple 5.13 shows what we suggest you put in this file, at least to run this example.
Our Environment
NOTE
You will have to put this in your home directory both on the server and on all
client machines.
5.8.4.3
Our packages here follow Sun's suggested naming convention of your
domain name, reversed, followed by your package names. It so happens that
Mr. Schwarz's domain is called multitool.net (named after his first
topic, Multitool Linux ), so we put all of these classes in a package called
net.multitool.RMIDemo .
For all of the examples in this section, as well as the following section on
building and running the client, assume that our current working directory is
the directory that contains the net directory of our source code.
The output you see in Example 5.14 includes the result of running our
client once. Note that the SessionImpl class doesn't terminate. It keeps
running to service clients indefinitely.
Compiling and Running the Server
Search WWH ::




Custom Search