我不能让编译器找到我想要的类 正是这个:
ctx.rebind("MyInterfaceImplementacja", ref);
。我可以请你纠正我吗?
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();}
}
}