这是源代码希望大家帮我看看
接口
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface RemoteInterface extends Remote{
String message(String message)throws RemoteException;
}
客户
import java.rmi.RMISecurityManager;
import java.rmi.Naming;
public class RemoteClient
{
public static void main(String args[]){
System.setSecurityManager(new RMISecurityManager());
try{
RemoteInterface server = (RemoteInterface)Naming.lookup("servertext");
String serverString = server.message("hello");
}
catch(Exception e){
System.out.println("e");
}
}
}
服务器
import java.rmi.Naming;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
public class RemoteObject extends UnicastRemoteObject implements RemoteInterface{
String name;
public RemoteObject(String  name) throws RemoteException{
super();
this.name=name;
}
public String message(String message) throws RemoteException{
String returnString = name+message;
System.out.println(returnString);
return returnString;
}
public static void main(String args[]){
try{
String myName = "servertext";
RemoteObject theserver = new RemoteObject(myName);
Naming.rebind(myName,theserver);
System.out.println("ksdkfksd");
}
catch(Exception e){
System.out.println(e);
}
}
}