以下都是正确的,编译没有问题,Java 文件和类文件都是在同一个路径下E:\>jdk_1.4.2\bin\rmi\,但就是在生成 框架和存根时出现了错误:E:\>jdk_1.4.2\bin\rmi\>rmic PerfectTime
error:Class PerfectTime not found.
1 error路径都没有问题呀,编译也通过了,那怎么还会出现这个问题!!!!!请问是为什么?PerfectTimeI类:
import java.rmi.*;public interface PerfectTimeI extends Remote
{
public long getPerfectTime ( ) throws RemoteException;
}PerfectTime类:import java.net.*;
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;public class PerfectTime extends UnicastRemoteObject implements PerfectTimeI
{
//默认构件器,也要“掷”出 RemoteException 违例
public PerfectTime ( ) throws RemoteException
{
super ( );
} public long getPerfectTime ( ) throws RemoteException
{
return System.currentTimeMillis ( );
} public static void main ( String [ ] args )
{
/* 创建和安装一个安全管理器,令其支持 RMI,作为 Java 开发包
的一部分,适用于 RMI 唯一一个是 RMISecurityManager */
System.setSecurityManager ( new RMISecurityManager ( ) ); try
{
PerfectTime pt = new PerfectTime ( ); //创建远程对象的一个或多个实例,下面是 PerfectTime 对象 /*向 RMI 远程对象注册表注册至少一个远程对象。一个远程对象拥有的方法
即可生成指向其它远程对象的句柄,这样,客户到注册表里访问一次,得到
第一个远程对象即可*/
Naming.bind ( "PerfectTime" , pt ); System.out.println ( "Ready to do Time" );
}
catch ( Exception e )
{
e.printStackTrace ( );
}
}
}
error:Class PerfectTime not found.
1 error路径都没有问题呀,编译也通过了,那怎么还会出现这个问题!!!!!请问是为什么?PerfectTimeI类:
import java.rmi.*;public interface PerfectTimeI extends Remote
{
public long getPerfectTime ( ) throws RemoteException;
}PerfectTime类:import java.net.*;
import java.rmi.*;
import java.rmi.registry.*;
import java.rmi.server.*;public class PerfectTime extends UnicastRemoteObject implements PerfectTimeI
{
//默认构件器,也要“掷”出 RemoteException 违例
public PerfectTime ( ) throws RemoteException
{
super ( );
} public long getPerfectTime ( ) throws RemoteException
{
return System.currentTimeMillis ( );
} public static void main ( String [ ] args )
{
/* 创建和安装一个安全管理器,令其支持 RMI,作为 Java 开发包
的一部分,适用于 RMI 唯一一个是 RMISecurityManager */
System.setSecurityManager ( new RMISecurityManager ( ) ); try
{
PerfectTime pt = new PerfectTime ( ); //创建远程对象的一个或多个实例,下面是 PerfectTime 对象 /*向 RMI 远程对象注册表注册至少一个远程对象。一个远程对象拥有的方法
即可生成指向其它远程对象的句柄,这样,客户到注册表里访问一次,得到
第一个远程对象即可*/
Naming.bind ( "PerfectTime" , pt ); System.out.println ( "Ready to do Time" );
}
catch ( Exception e )
{
e.printStackTrace ( );
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货