当前位置: 技术问答>java相关
看看下面的小程序,错在哪里了?
来源: 互联网 发布时间:2015-04-19
本文导语: 我很菜了。看看吧 出错信息:"ShowServer.java": Error #: 200 : '}' expected at line 47, column 3 package mycorba; /** * Title: * Description: * Copyright: Copyright (c) 2002 * Company: * @author * @version 1.0 */ import Mod...
我很菜了。看看吧
出错信息:"ShowServer.java": Error #: 200 : '}' expected at line 47, column 3
package mycorba;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2002
* Company:
* @author
* @version 1.0
*/
import Module1.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
public class ShowObject extends _ShowImplBase
{
public String ShowName()
{
return "nMy name is Seymour!!n";
}
}
public class ShowServer {
public static void main(String args[])
{
try{
// 创建和初始化 ORB
ORB orb = ORB.init(args, null);
// 创建服务对象并将其向 ORB 注册
ShowObject ShowRef = new ShowObject();
orb.connect(ShowRef);
// 获取根命名上下文
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
// 绑定命名中的对象引用
NameComponent nc = new NameComponent("Module1", "");
NameComponent path[] = {nc};
ncRef.rebind(path, ShowRef);
// 等待来自客户机的调用
java.lang.Object sync = new java.lang.Object();
synchronized (sync) {
sync.wait();
}
} catch (Exception e) {
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
}
出错信息:"ShowServer.java": Error #: 200 : '}' expected at line 47, column 3
package mycorba;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2002
* Company:
* @author
* @version 1.0
*/
import Module1.*;
import org.omg.CosNaming.*;
import org.omg.CosNaming.NamingContextPackage.*;
import org.omg.CORBA.*;
public class ShowObject extends _ShowImplBase
{
public String ShowName()
{
return "nMy name is Seymour!!n";
}
}
public class ShowServer {
public static void main(String args[])
{
try{
// 创建和初始化 ORB
ORB orb = ORB.init(args, null);
// 创建服务对象并将其向 ORB 注册
ShowObject ShowRef = new ShowObject();
orb.connect(ShowRef);
// 获取根命名上下文
org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
// 绑定命名中的对象引用
NameComponent nc = new NameComponent("Module1", "");
NameComponent path[] = {nc};
ncRef.rebind(path, ShowRef);
// 等待来自客户机的调用
java.lang.Object sync = new java.lang.Object();
synchronized (sync) {
sync.wait();
}
} catch (Exception e) {
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
}
|
在最后一行加一个}
|
"ShowObject.java": Error #: 482 : duplicate definition of class
不是明明写了吗,发现重复定义了类.
不是明明写了吗,发现重复定义了类.
|
一个文件只能有一个public类