2014-01-31 59 views
0

我想在運行時將一些jar文件添加到我的二進制文件中,但我不斷收到錯誤。我在Windows機器上運行它。我的代碼位於名爲SeleniumTest的目錄中。在啓動時將jar文件添加到classpath中

這裏是我用來編譯命令:

javac SeleniumTest\src\com\src\test\First.java -d SeleniumTest\bin -cp SeleniumTest\lib\junit-4.10.jar;SeleniumTest\lib\selenium-java-2.39.0.jar;SeleniumTest\lib\selenium-server-standalone-2.39.0.jar 

此成功合作。然而,當我嘗試運行此命令:

java -cp SeleniumTest\lib\junit-4.10.jar;SeleniumTest\lib\selenium-java-2.39.0.jar;SeleniumTest\lib\selenium-server-standalone-2.39.0.jar SeleniumTest\bin com.src.test.First 

我得到一個消息:

Error: Could not find or load main class SeleniumTest\bin 

我的代碼,First.java存在

SeleniumTest\bin\com\src\test 

我在做什麼錯?

+0

你有沒有考慮過使用[搖籃](http://www.gradle.org/),[Maven的(HTTP://行家.apache.org /)或[Ant](http://ant.apache.org/)/ [Ivy](http://ant.apache.org/ivy/)來管理你的構建和依賴關係? –

回答

1

試試這個

java -cp "SeleniumTest\lib\junit-4.10.jar;SeleniumTest\lib\selenium-java-2.39.0.jar;SeleniumTest\lib\selenium-server-standalone-2.39.0.jar;SeleniumTest\bin" com.src.test.First 
+0

沒有用。我不需要指定SeleniumTest目錄嗎? – user1801060

+0

@ user1801060這個例子的錯誤打印輸出是什麼? – Andremoniy

+0

'First.class'存在於哪裏? – laz

0

嘗試以下

java -cp SeleniumTest\lib\junit-4.10.jar;SeleniumTest\lib\selenium-java-2.39.0.jar;SeleniumTest\lib\selenium-server-standalone-2.39.0.jar SeleniumTest\bin SeleniumTest\src\com\src\test\First 
+0

@ satish-srg:「錯誤:無法找到或加載主類SeleniumTest \ bin \ com \ src \ test \ First」 – user1801060

相關問題