找不到符号' DirImp1'

时间:2015-02-15 15:58:59

标签: java corba

Corba客户档案:

import DirApp.*;  
import org.omg.CosNaming.*;  
import org.omg.CosNaming.NamingContextPackage.*;  
import org.omg.CORBA.*;  
import java.util.Scanner;  
import java.lang.*;  

public class DirClient  
{  
 static DirInterface DirImpl;  

 public static void main(String args[])  
 {  int ch=0;

 try{  
             System.out.println("\n-----------------------------------  ");  
    System.out.println("DirClient: Looking up DirServer...");  

     // create and initialize the ORB  
     ORB orb = ORB.init(args, null);  

     // get the root naming context  
     org.omg.CORBA.Object objRef =   
     orb.resolve_initial_references("NameService");  

     // Use NamingContextExt instead of NamingContext.   
     // This is part of the Interoperable naming Service.    
     NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);  

     // resolve the Object Reference in Naming  
     String name = "DirOperations";  
     DirImpl = DirInterfaceHelper.narrow(ncRef.resolve_str(name));  

     System.out.print("DirClient: Obtained a handle on server object:\n\n");  
     System.out.println(DirImpl);  

     Scanner sc=new Scanner(System.in); 
       do  
       {  

       System.out.println("1.add details 2. get details 3.Get phone number 
       0.exit");        
       ch=sc.nextInt();
       switch(ch){

                 case 1:
                 System.out.println("Input company name");
                 String namec=sc.nextLine();
                 System.out.println("Input company number");
                 String numbc=sc.next();
                 System.out.println("Input Details for company");
                 String detc=sc.nextLine();
                 DirImp1.adddetails(namec,numbc,detc);
                 break;

                 case 2:
                 System.out.println("Input company name to get itsdetails"); 
                 String name2=sc.next();
                 String det=DirImp1.getDetails(name2);
                 System.out.println(det);
                 System.out.println("Do you want to rate the company   
                 (y/n)?");
                 String rate=sc.next();
                 DirImp1.Rate(rate,name2);
                 break;

                 case 3:
                 System.out.println("Enter name of the company to get 
                 contact number");
                 String name1=sc.next();
                 String xx=DirImp1.getContact(name1);
                 System.out.println(xx);break;

                 case 0:System.exit(0);

                 }


        }while (ch!=0);


            DirImpl.shutdown();  
    }  
        catch (Exception e)   
        {     
             //System.err.println("ERROR: " + e);     
             //e.printStackTrace(System.out);     
             System.out.println("\n---------------------------------");  
             System.out.println("DirClient: Some Error Has Occurred !");  
             System.out.println("\n--------------------------------");  
        }  

        System.out.println("\nDirServer: Exiting...");  
        System.out.println("\n----------------------");  
    }  
 }  

1 个答案:

答案 0 :(得分:1)

您已将变量声明为DirImpl,但您使用的是DirImp1,因此请将其更改为DirImpl或将变量声明为DirImp1