KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Client


1 import org.omg.CORBA.*;
2
3 import java.io.*;
4 /**
5  * Client.java
6  *
7  *
8  * Created: Mon Sep 3 19:28:34 2001
9  *
10  * @author Nicolas Noffke
11  * @version $Id: Client.java,v 1.1 2002/01/22 08:18:48 nicolas Exp $
12  */

13
14 public class Client
15 {
16
17     public static void main( String JavaDoc[] args )
18         throws Exception JavaDoc
19     {
20         if( args.length != 1 )
21     {
22             System.out.println( "Usage: jaco Client <ior_file>" );
23             System.exit( 1 );
24         }
25
26
27         File f = new File( args[ 0 ] );
28
29         //check if file exists
30
if( ! f.exists() )
31         {
32             System.out.println("File " + args[0] +
33                                " does not exist.");
34                 
35             System.exit( -1 );
36         }
37             
38         //check if args[0] points to a directory
39
if( f.isDirectory() )
40         {
41             System.out.println("File " + args[0] +
42                                " is a directory.");
43                 
44             System.exit( -1 );
45         }
46
47         // initialize the ORB.
48
org.omg.CORBA.ORB JavaDoc orb = org.omg.CORBA.ORB.init( args, null );
49
50         BufferedReader br =
51             new BufferedReader( new FileReader( f ));
52
53         // get object reference from command-line argument file
54
org.omg.CORBA.Object JavaDoc obj =
55             orb.string_to_object( br.readLine() );
56
57         br.close();
58
59         GoodDay gd = GoodDayHelper.narrow( obj );
60
61         System.out.println( "hello_simple(): " + gd.hello_simple());
62         System.out.println( "hello_wide(): " +
63                             gd.hello_wide( "daß düdelt und dödelt"));
64
65         try
66         {
67             gd.test();
68         }
69         catch( GoodDayPackage.WStringException wse )
70         {
71             System.out.println("Exception: " + wse.why );
72         }
73     }
74 }// Client
75

76
Popular Tags