I’m following a basic Java RMI tutorial for a distributed system here: http://people.cs.aau.dk/~bnielsen/DS-E08/Java-RMI-Tutorial/
I’m having a problem with compiling my Server implementation.
The error is as follows:
RMIServer.java:5: cannot find symbol
symbol: class ServerInterface
public class RMIServer extends UnicastRemoteObject implements ServerInterface {
^
1 error
This is my server implementation:
package rmiTutorial;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.*;
public class RMIServer extends UnicastRemoteObject implements ServerInterface {
private String myString = " ";
//Default constructor
public RMIServer() throws RemoteException {
super();
}
//inherited methods
public void setString(String s) throws RemoteException {
this.myString =s;
}
public String getString() throws RemoteException{
return myString;
}
//main: instantiate and register server object
public static void main(String args[]){
try{
String name = "RMIServer";
System.out.println("Registering as: \"" + name + "\"");
RMIServer serverObject = new RMIServer();
Naming.rebind(name, serverObject);
System.out.println(name + " ready...");
} catch (Exception registryEx){
System.out.println(registryEx);
}
}
}
ServerInterface:
package rmiTutorial;
import java.rmi.*;
public interface ServerInterface {
public String getString() throws RemoteException;
public void setString(String s) throws RemoteException;
}
The RMIServer class and the ServerInterface are both in the same package.
I’ve followed the tutorial exactly, so I don’t really understand how I’ve managed to break it!
Any help would be greatly appreciated!
Thanks.
Tori
I suspect you’re compiling these separately. The tutorial isn’t clear on this, but you need to compile these together (in the simplest case):
(including other appropriate flags as necessary – libs, classpath etc.).
You need to compile the two together such that the compiler can find the
ServerInterfacewhen it builds theRMIServer. You can compile theServerInterfacefirst, but then you need to compile theRMIServerwith a suitable classpath reference such that it can find the interface.