package hello; import org.omg.CORBA.*; import java.io.*; import java.awt.*; public class Client extends java.applet.Applet { public static void main(String args[]) { try { // // Create ORB // ORB orb = ORB.init(args, new java.util.Properties()); // // Get "hello" object // String ref = null; try { String refFile = "Hello.ref"; FileInputStream file = new FileInputStream(refFile); DataInputStream in = new DataInputStream(file); ref = in.readLine(); file.close(); } catch(IOException ex) { System.err.println("Can't read from `" + ex.getMessage() + "'"); System.exit(1); } org.omg.CORBA.Object obj = orb.string_to_object(ref); if(obj == null) throw new RuntimeException(); Hello hello = HelloHelper.narrow(obj); // // Main loop // System.out.println("Enter 'h' for hello or 'x' for exit:"); int c; try { String input; do { System.out.print("> "); DataInputStream dataIn = new DataInputStream(System.in); input = dataIn.readLine(); if(input.equals("h")) hello.hello(); } while(!input.equals("x")); } catch(IOException ex) { System.err.println("Can't read from `" + ex.getMessage() + "'"); System.exit(1); } System.exit(0); } catch(COMM_FAILURE ex) { System.err.println(ex.getMessage()); ex.printStackTrace(); System.exit(1); } } }