找不到符号“DirImp1”[关闭]
Posted
技术标签:
【中文标题】找不到符号“DirImp1”[关闭]【英文标题】:Cannot find symbol 'DirImp1' [closed] 【发布时间】:2015-02-15 15:58:58 【问题描述】: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】:您已将变量声明为DirImpl
,但您使用的是DirImp1
,因此请将它们更改为DirImpl
或将变量声明为DirImp1
。
【讨论】:
以上是关于找不到符号“DirImp1”[关闭]的主要内容,如果未能解决你的问题,请参考以下文章