2010-06-05 55 views
0

我需要使用命令行运行我的RMI服务器RmiEncodingServer), 我的类文件驻留在此文件夹中:运行在命令行的RMI服务器和eclipse

C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerClasses 
封装 hw2.rmi.server

。 代码库驻留此文件夹中:

C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerCodeBase 

在包hw2.rmi.server

我使用命令行:

java –classpath C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerClasses\ -Djava.rmi.server.codebase=file:/C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerCodeBase -Djava.security.policy=C:\workspace\distributedhw2\permissions.policy hw2.rmi.server.RmiEncodingServer 

但我得到一个 “找不到类” 异常如下:

Exception in thread "main" java.lang.NoClassDefFoundError: ûclasspath 
Caused by: java.lang.ClassNotFoundException: ûclasspath 
     at java.net.URLClassLoader$1.run(Unknown Source) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at java.net.URLClassLoader.findClass(Unknown Source) 
     at java.lang.ClassLoader.loadClass(Unknown Source) 
     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) 
     at java.lang.ClassLoader.loadClass(Unknown Source) 
Could not find the main class: GÇôclasspath. Program will exit. 

我在哪里出了错?

还,如果你能提供关于如何在Eclipse中运行服务器的说明,我增加了以下内容作为VM参数,但我得到一个类未发现异常的一类是在RmiServerCodeBase:

-Djava.security.policy=C:\workspace\distributedhw2\permissions.policy -Djava.rmi.server.codebase=file:/C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerCodeBase 

感谢

回答

1

我发现的问题是,我试图参照的.java文件在我的代码库,而不是的.class文件,我假设属性格式名“代码库”是一个有点误导。所以如果你想这样做在你的RMI服务器,你可以这样来做:

String codeBasePath = "file:/C:/workspace/distributedhw2/" 
     + "AgencyServers/RmiEncodingServer/RmiServerClasses/"; 
     System.setProperty("java.rmi.server.codebase",codeBasePath); 

或者只是通过以下的VM参数:

-Djava.security.policy=C:\workspace\distributedhw2\permissions.policy -Djava.rmi.server.codebase=file:/C:\workspace\distributedhw2\AgencyServers\RmiEncodingServer\RmiServerClasses