我该怎么做,当我有这个错误:
java.rmi。UnmarshalException:解组参数出错;嵌套异常是:java.lang.ClassNotFoundException
我在"我的计算机"的属性中添加了JDK中bin的路径:这个"C:Program FilesJavajdk1.6.0_19bin"
和我输入运行-cmd-
cd C:UsersuserDocumentsNetBeansProjectsCountRMIsrccountrmi
start rmiregistry
和我运行的服务器,所以这个错误出现
java.rmi。UnmarshalException:解组参数出错;嵌套异常是:java.lang.ClassNotFoundException
感谢u
考虑一下Cajo项目。它包装了RMI,所以您不必担心启动RMI注册表之类的事情。请看下面一个来自Cajo wiki页面的例子
Duck.java
public interface Duck {
boolean looks();
boolean walks();
boolean talks();
}
DuckServer.java
import gnu.cajo.invoke.Remote;
import gnu.cajo.utils.ItemServer;
public class DuckServer implements Duck {
public boolean looks() {
System.out.println("hi there!");
return true;
}
public boolean walks() {
System.out.println("waddle waddle");
return true;
}
public boolean talks() {
System.out.println("quack quack!");
return true;
}
public static void main(String args[]) throws Exception { // simple unit test
Remote.config(null, 1198, null, 0); // use cajo port 1198
ItemServer.bind(new DuckServer(), "Donald");
System.out.println("duck server running");
}
}
DuckClient.java
import gnu.cajo.utils.extra.TransparentItemProxy;
public class DuckClient { // try out DuckServer
public static void main(String args[]) throws Exception {
Duck duck = (Duck)TransparentItemProxy.getItem(
"//serverHost:1198/Donald",
new Class[] { Duck.class }
);
System.out.println("looks like = " + duck.looks());
System.out.println("walks like = " + duck.walks());
System.out.println("talks like = " + duck.talks());
}
}
时间已经过去了,但也许这对某人有所帮助。当你把
cd C:UsersuserDocumentsNetBeansProjectsCountRMIsrccountrmi
您正在设置源文件的de path,但您必须将其设置为类文件,以这种方式
cd C:UsersuserDocumentsNetBeansProjectsCountRMIbuildclasses
和启动rmiregistry
,当然
至少对我来说还行