我以前写的,应该没有问题。
________________________________________________________________________
RemotePrinter.java
^^^^^^^
package remoteprinter;import java.rmi.*;public interface RemotePrinter extends Remote{
  public void GoPrint() throws RemoteException;
}________________________________________________________________
ServerPrinter.java
^^^^^^
package remoteprinter;
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.util.*;public class ServerPrinter extends UnicastRemoteObject implements RemotePrinter{

private static int CallTimes=0;

public ServerPrinter() throws RemoteException{super();}

public void GoPrint() throws RemoteException{
        CallTimes+=1;
         System.out.println(" Go Print for "+ CallTimes +" times!\n");
   }
  
   public static void main(String[] args) {
     try{
     System.out.println("Prepare to Start Serving! Please Wait...");
     ServerPrinter printer = new ServerPrinter();
     System.out.println("Print Server Ready! Start Serving...");
    
     LocateRegistry.createRegistry();
     Registry registry = LocateRegistry.getRegistry();
     registry.rebind("FirstRemote", printer);
       System.out.println("Server open and ready for customers!!!");
     }
catch(Exception e){
       System.err.println(e.toString());
     }
   }
}
__________________________________________________________________________
ClientPrinter.java
^^^^^^
package remoteprinter;import java.util.*;
import java.rmi.*;
import java.rmi.registry.*;
import javax.swing.*;public class ClientPrinter{
   public static void main(String[] args){
      try{
        //OLD Implementation
        String url= System.getProperty("ClientPrinter","rmi://localhost/FirstRemote");
        RemotePrinter obj = (RemotePrinter)Naming.lookup(url);
          
        obj.GoPrint();
      }
      catch(Exception e){
        System.err.println(e.toString());
      }
    }
  
}