我下面的一個基本的Java RMI教程這裏分佈式系統:http://people.cs.aau.dk/~bnielsen/DS-E08/Java-RMI-Tutorial/Java RMI的教程編譯時錯誤 - 接口未發現
我在與我的編譯Server實現的問題。
的錯誤如下:
RMIServer.java:5: cannot find symbol
symbol: class ServerInterface
public class RMIServer extends UnicastRemoteObject implements ServerInterface {
^
1 error
這是我的服務器上執行:
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;
}
的RMIServer的類和ServerInterface都在同一個包。 我已經完全按照教程進行了練習,所以我不太瞭解我如何設法打破它!
任何幫助將不勝感激! 謝謝。
托裏
你是如何編譯這些的? –
你必須先編譯ServerInterface然後RMIServer – Suranga
最初我編譯了ServerInterface,然後試圖單獨編譯RMIServer。 – ToriBean