Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 尝试生成存根文件时出错_Java_Rmi_Stub - Fatal编程技术网

Java 尝试生成存根文件时出错

Java 尝试生成存根文件时出错,java,rmi,stub,Java,Rmi,Stub,当我尝试使用以下命令生成存根文件时:rmic RemoteMethodImpl 我得到以下错误: error: File .\RemoteMethodImpl.class does not contain type RemoteMethodImpl as expected, but type InterfaceImplementation.RemoteMethodImpl. Please remove the file, or make sure it appears in the correc

当我尝试使用以下命令生成存根文件时:
rmic RemoteMethodImpl
我得到以下错误:

error: File .\RemoteMethodImpl.class does not contain type RemoteMethodImpl as expected, but type InterfaceImplementation.RemoteMethodImpl. Please remove the file, or make sure it appears in the correct subdirectory of the class path.
error: Class RemoteMethodImpl not found.
2 errors
这是什么错误?为什么我会得到这个

应@Shashank Kadne的要求

包接口实现;
导入Interfaces.RemoteMethodIntf;
导入java.rmi.server.UnicastRemoteObject;
导入java.rmi.RemoteException;
导入Design.Main\u Design\u客户端;
/**
*
*@author program-o-steve
*/
公共类RemoteMethodImpl扩展UnicastRemoteObject实现RemoteMethodIntf{
public RemoteMethodImpl()引发异常{}
@凌驾
公共无效发送(字符串IP、字符串消息)引发RemoteException{
Main_Design_Client mdc=新的Main_Design_Client();
mdc.jTextArea1.setText(“来自:+IP的消息”);
mdc.jTextArea1.setText(“消息:”+消息);
}

}

我假设您位于“InterfaceImplementation”文件夹外的目录中


执行:
rmic InterfaceImplementation.RemoteMethodImpl

我假设您位于“InterfaceImplementation”文件夹外的目录中

执行:
rmic接口实现。RemoteMethodImpl

当我尝试生成存根文件时

停在那里。你已经八年不需要这么做了

public RemoteMethodImpl()引发异常{}

只要将其更改为调用
super()
,您就不需要存根了。有关
java.rmi.server.UnicastRemoteObject
,请参阅Javadoc的序言

当我尝试生成存根文件时

停在那里。你已经八年不需要这么做了

public RemoteMethodImpl()引发异常{}

只要将其更改为调用
super()
,您就不需要存根了。参见Javadoc的序言,了解
java.rmi.server.UnicastRemoteObject

是的,我正在尝试

% rmic GumballMachine
但在读了这本书后,它发生了变化

% rmic gumball\GumballMachine

这很好用。有时候,我想知道我是一个多么愚蠢的人

是的,我试过了

% rmic GumballMachine
但在读了这本书后,它发生了变化

% rmic gumball\GumballMachine


这很好用。有时候,我想知道我是一个多么愚蠢的人

它是否扩展了UnicastRemoteObject?此外,请在执行rmic之前尝试设置类路径。是否可以上载RemoteMethodImpl.java?@Shashank Kadne查看正在执行rmic命令的文件夹?。。从InterfaceImplementation文件夹内或从InterfaceImplementation文件夹外??请参阅我的答案…它应该可以工作..它是否扩展了UnicastRemoteObject?此外,请在执行rmic之前尝试设置类路径。是否可以上载RemoteMethodImpl.java?@Shashank Kadne查看正在执行rmic命令的文件夹?。。从InterfaceImplementation文件夹内或从InterfaceImplementation文件夹外??查看我的答案…它应该有效..是的,有效!但是你能解释一下为什么我从内部编译时不能得到一个吗?这是因为rmic命令中命名的类必须是使用javac命令成功编译的类,并且必须是完全符合包条件的类。这里,您的RemoteMethodImpl实际上是在PackageInterfaceImplement中。所以它在执行“rmic RemoteMethodImpl”时给了您一个异常是的,这很有效!但是你能解释一下为什么我从内部编译时不能得到一个吗?这是因为rmic命令中命名的类必须是使用javac命令成功编译的类,并且必须是完全符合包条件的类。这里,您的RemoteMethodImpl实际上是在PackageInterfaceImplement中。因此,它在执行“rmic RemoteMethodImpl”时为您提供了异常