/**
*java 文件
*/import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.util.Date;public class HelloServer extends UnicastRemoteObject implements HelloInterface{   public HelloServer() throws RemoteException{
       super();// Call the superclass constructor to export this object
   }   public String sayHello() throws RemoteException{
       return "Hello World, the current system time is " + new Date();
    }
}import java.rmi.*;public class HelloClient {   public static void main(String args[]) {
      if (System.getSecurityManager() == null)
         System.setSecurityManager(new RMISecurityManager());
      try {
         HelloInterface obj = (HelloInterface) Naming.lookup("/HelloServer");
         String message = obj.sayHello();
         System.out.println(message);
      } catch (Exception e) {
         System.out.println("HelloClient exception: " +e);
      }
   }
}public interface HelloInterface extends java.rmi.Remote {   // This method is called by remote clients and is implemented by the 
   // remote object
   public String sayHello() throws java.rmi.RemoteException;
}
import java.rmi.*;public class RegisterIt {   public static void main(String args[]) {
      try {
         // Instantiate the object
         HelloServer obj = new HelloServer();
         System.out.println("Object instantiated"  +obj); 
         Naming.rebind ("/HelloServer", obj); 
         System.out.println("HelloServer bound in registry");
      } catch (Exception e) {
         System.out.println(e);
      }
   }
}/*
*registerit.policy
/*
grant {
   // Allow everything for now
   permission java.security.AllPermission;
};

解决方案 »

  1.   

    把几个.java文件删掉,只保留.class,再运行试试
      

  2.   

    /*
    *把几个.java文件删掉,只保留.class,再运行试试
    /*error: Class HelloServer not found.
      

  3.   

    怎么初学RMI没有这样的问题吗?
      

  4.   

    first , you must sure your JDK ClassPath is not mistake , okay ?
    second , you java files name is exactly same to the your class name .
     now ,try ! any question ,please write to [email protected] , I would like to 
    support some Java friends!
      

  5.   

    你在D0S下输入PATH命令,如果抱错说明JAVA环境变量设置有问题?