1 | import HelloApp.*; |
2 | import org.omg.CosNaming.*; |
3 | import org.omg.CORBA.*; |
4 | public class HelloClient { |
5 | public static void main(String args[]) { |
6 | try{ // create and initialize the ORB |
7 | ORB orb = ORB.init(args, null); |
8 | // get the root naming context |
9 | org.omg.CORBA.Object objRef = |
10 | orb.resolve_initial_references("NameService"); |
11 | NamingContext ncRef = NamingContextHelper.narrow(objRef); |
12 | // resolve the Object Reference in Naming |
13 | NameComponent nc = new NameComponent("Hello", ""); |
14 | NameComponent path[] = {nc}; |
15 | Hello HelloRef = HelloHelper.narrow(ncRef.resolve(path)); |
16 | // call the Hello server object and print results |
17 | String Hello = HelloRef.sayHello(); |
18 | System.out.println(Hello); |
19 | } . . . // catch exceptions |
20 | } |