import java.io.*; import org.omg.CORBA.*; import org.omg.CosNaming.*; import SimpleHelloWorld.DontCallMeException; public class SimpleHelloWorldClient { public static void main(String args[]) { try { // initialize the ORB ORB orb = ORB.init(args, null); //org.omg.CORBA.Object obj = orb.string_to_object(args[0]); //get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references( "NameService"); if (objRef == null) { System.out.println("can't find the naming servive."); } NamingContext ncRef = NamingContextHelper.narrow(objRef); //resolve the Object Reference in Naming NameComponent nc = new NameComponent("GoodDay", ""); NameComponent path[] = {nc}; try { ShortHolder minute = new ShortHolder(); ShortHolder hour = new ShortHolder(); SimpleHelloWorld.GoodDay good_day = SimpleHelloWorld.GoodDayHelper.narrow(ncRef.resolve(path)); System.out.println(good_day.hello()); System.out.println(good_day.hell(hour, minute)); if(minute.value < 10) { System.out.println("It's " + hour.value + ":0" + minute.value + "."); } else { System.out.println("It's " + hour.value + ":" + minute.value + "."); } try { good_day.dontCallMe(); }catch (DontCallMeException ex) { System.out.println("Received an DontCallMeException says:" + ex.message); } } catch(Exception ex) { System.err.println("CORBA communication error:"); System.err.println(ex); } } catch(Exception ex) { System.err.println("CORBA initialize error:"); System.err.println(ex); } } }