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 = orb.resolve_initial_references("NameService"); |
10 | NamingContext ncRef = NamingContextHelper.narrow(objRef); |
11 | // resolve the Object Reference in Naming |
12 | NameComponent nc = new NameComponent("Hello", ""); |
13 | NameComponent path[] = {nc}; |
14 | Hello HelloRef = HelloHelper.narrow(ncRef.resolve(path)); |
15 | // call the Hello server object and print results |
16 | String Hello = HelloRef.sayHello(); |
17 | System.out.println(Hello); |
18 | } catch (Exception e) { |
19 | System.out.println("ERROR : " + e) ; |
20 | e.printStackTrace(System.out); |
21 | }}} |