我無法使編譯器找到我想要的類正是這樣的: ctx.rebind("MyInterfaceImplementacja", ref);
。我能請你糾正我嗎?RMI中的ClassNotFoundException Java
package Pakiet;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface MyInterface extends Remote {
public String echo(String napis) throws RemoteException;
public int dodaj(int wrt1, int wrt2) throws RemoteException;
}
package Pakiet;
import java.rmi.RemoteException;
import javax.rmi.PortableRemoteObject;
public class MyInterfaceImplementacja extends PortableRemoteObject implements MyInterface {
protected MyInterfaceImplementacja() throws RemoteException {
super();
}
@Override
public String echo(String napis) throws RemoteException {
return "echo" + napis;
}
@Override
public int dodaj(int wrt1, int wrt2) throws RemoteException {
return wrt1 + wrt2;
}
}
public class MyInterfaceSerwer {
public static void main(String[] args) {
try{
MyInterfaceImplementacja ref = new MyInterfaceImplementacja();
Context ctx = new InitialContext();
ctx.rebind("MyInterfaceImplementacja", ref);
}catch(Exception e){e.printStackTrace();}
}
}
這幾乎是[相同的問題(http://stackoverflow.com/q/10648026/509303)你問了幾分鐘後或更早版本。等待答案,而不是垃圾郵件問題。 – buc
您是否收到編譯錯誤或運行時異常? – EJP