import org.omg.CosNaming.* ; import org.omg.CosNaming.NamingContext.* ; import org.omg.CORBA.* ; public class stock_market_server { public static void main (String args[]) { try { ORB orb = ORB.init (args, null); /* We give the arg at the command prompt */ /* The servant will do the work for us */ stock_server servent = new stock_server(); orb.connect (servent); /* Let ORB know about it */ /* Resolve the initial Reference */ org.omg.CORBA.Object objRef = orb.resolve_initial_references ("NameService"); /* Narrow it down to namingcontext */ NamingContext ncRef = NamingContextHelper.narrow(objRef); /* Form the Name component */ NameComponent nc = new NameComponent ("stock_server","") ; NameComponent path[] = {nc} ; /* Bind it */ ncRef.rebind (path, servent) ; java.lang.Object sync = new java.lang.Object(); synchronized (sync){ /* wait for invocation */ sync.wait() ; } }catch (Exception e) { System.err.println ( e ) ; e.printStackTrace () ; } } }