Reputation: 27
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
Upvotes: 0
Views: 2733
Reputation: 272277
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):
javac rmiTutorial/RMIServer.java rmiTutorial/ServerInterface.java
(including other appropriate flags as necessary - libs, classpath etc.).
You need to compile the two together such that the compiler can find the ServerInterface
when it builds the RMIServer
. You can compile the ServerInterface
first, but then you need to compile the RMIServer
with a suitable classpath reference such that it can find the interface.
Upvotes: 1