2010-06-05 54 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