The Java Program: rmi1/OpTest.java
1 package rmi1;
2
3 import java.rmi.*;
4 import java.rmi.server.*;
5
6 // The OpTest class looks up a remote object registered as
7 // "operator" and invokes the "call" operation on it. The
8 // java.rmi.Naming class is used to perform the lookup. The
9 // "call" operation will be performed in a remote process.
10
11 public class OpTest {
12
13 // Look up a remote "operator" and invoke "call".
14
15 public static void main(String[] args) {
16
17 // rmi requires an RMISecurityManager in order to access
18 // remote objects.
19
20 System.setSecurityManager(new RMISecurityManager());
21
22 try {
23
24 // Look up a remote "operator".
25
26 RemOp ro = (RemOp)Naming.lookup("operator");
27
28 // Invoke the call operation remotely.
29
30 ro.call();
31
32 } catch (Exception x) {
33 x.printStackTrace();
34 System.exit(-1);
35 }
36 }
37 }
38