2012-09-04 43 views
0

在Eclipse Indigo(在Mac OSX上),我有一個項目'測試'。在這個項目中,我有一個包'test1'。在這個包中,我有一個Test.java類。如何在Eclipse中配置外部工具來運行jar文件並加載其他類文件?

總之文件結構爲:測試/ src目錄/ Test.java和
測試/斌/的Test.class

我在lib文件夾庫mylib.jar

我還有一個數據文件,名爲info.dat。在info.dat中,有關於加載哪個類的信息。例如,在info.dat,我指定:類=測試 然後,當我運行:

$ java -jar lib/mylib.jar info.dat 

(NOTE: this works if I run this command in terminal and have class file in the same folder with info.dat) 

在mylib.jar主要功能將加載的Test.class。

我正在使用外部工具來實現這一點。這裏是我的外部工具設置:

Location: /usr/bin/java 
Working Location: /path/to/Test_folder 
Argument: -cp . -jar lib/mylib.jar bin/test1/info.dat 

然而,當我嘗試運行,我得到這個錯誤:

LOADING INFO FROM FILE bin/test1/info.dat 
=> Current directory=[not include because not important] 
=> Full pathname=[not include because not important] 
java.lang.ClassNotFoundException: Test 

我也試圖改變類= test.Test在info.dat但得到了類似的錯誤

java.lang.ClassNotFoundException: test1.Test 

結果顯示info.dat加載正常,但類文件的路徑不正確。我應該如何配置外部工具來完成我所需要的工作?有人可以給我一些指導嗎?

非常感謝,

回答

1

這是一個簡單的解決方案與運行配置。我只需要從Java應用程序中的mylib.jar中選擇主類,並將info.dat放在參數字段中。

對不起,浪費資源在這裏。

相關問題