import HelloApp.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; public class HelloServer { public static void main(string args[]) { try { // Create the ORB ORB orb = ORB.init(args,null); // Instantiate the servant object HelloServant helloRef = new HelloServant(); // Connect servant to the ORB orb.connect(helloRef); //Registering the servant org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContext ncRef = NamingContextHelper.narrow(objRef); NameComponent nc = new NameComponent("Hello",""); NameComponent path[] = {nc}; ncRef.rebind(path, helloRef); // Wait for invocation java.lang.Object sync = new java.Lang.Object(); synchronized(sync) { sync.wait(); } } catch(Exception e) { System.out.println(e); e.printStackTrace(System.out); } } } class HelloServant extends _HelloImplBase { public String sayHello() { return "\nHelloWorld!\n"; } }