Hello, I am new to RMI can following java.sun.com's tutorial, I develop
the following program , however I keep getting a ClassCastException
when I try to cast the remote ojbect into it's interface . I've been
stuck 2 days and doesn't have a clue yet!
//a remote interface:
public interface MyInterface extends Remote{
...
}
//its implement on server
package server;
public MyImpl extends UnicastRemoteObject implements MyInterface{
...
}
ok , now on the client side,NOTE: different package:
//client code
package client
class Client {
...
String name = "...";
MyInterface remote = (MyInterface)Naming(name); //ClassCastException here
....
}
after all codes are done, I have the rmiregistry started ok,
the server started ok
Now when I try to start running my client, it gave me a ClassCastException on main.
when I try println(Naming(name)), it does return the remote object.
I kind of feel that this problem is somehow related to the path setting . I don't know how and why...
please any help would be greatly appreciated!
Thank you