I worked a simple program But when you run the client at the command This error appears
HelloClient exception: java.lang.UnsupportedOperationException: Not supported yet.
this my coded
Interface class
import java.rmi.*;
public interface HelloInterface extends Remote {
public String say() throws RemoteException;
}
implement class
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
/**
*
* @author x
*/
public class HelloServerImpl extends UnicastRemoteObject implements HelloInterface {
private String message;
public HelloServerImpl(String msg)throws RemoteException{
message = msg;
}
@Override
public String say() throws RemoteException {
throw new UnsupportedOperationException("Not supported yet.");
}
}
Server class
import java.rmi.Naming;
/**
*
* @author x
*/
public class HelloServer {
public static void main (String []args ){
try {
Naming.rebind("HELLOSERVER", new HelloServerImpl("Hello word"));
System.out.println("Hello Server is ready.");
} catch (Exception ex) {
System.out.println("Hello server failed: "+ ex);
}
}
}
Client class
import java.rmi.Naming;
/**
*
* @author x
*/
public class HelloClient {
public static void main(String[]args){
HelloInterface hello;
String url = "rmi://localhost/HELLOSERVER";
try {
hello = (HelloInterface)Naming.lookup(url);
System.out.println(hello.say());
} catch (Exception ex) {
System.err.println("HelloClient exception: " + ex);
}
}
}
I am prepared to write the steps but still the same error
why??
Well you wrote this yourself:
Of course it throws an exception. Try to actually return a string: