2013-05-12 75 views
2

我從here下載了netty並解壓縮/解壓縮了它。在netty上運行丟棄服務器

現在,我想運行Discard Server,這是大多數netty教程中的第一個示例。我可以看到io/netty/example/discard/DiscardServer.class,我知道這也有主要方法。

我的問題是:我如何運行丟棄服務器?

我試圖

java -jar netty-common-4.0.0.CR2.jar io.netty.example.discard.DiscardServer 

這將產生:

Failed to load Main-Class manifest attribute from netty-common-4.0.0.CR2.jar

我試圖unjarring罐子,把主類名如下清單文件:

Main-Class: io.netty.example.discard.DiscardServer 

運行罐子仍然給我錯誤:

Could not find the main class: io.netty.example.discard.DiscardServer. Program will exit.

回答

1

您只能在java中加載netty-common-4.0.0.CR2.jar,但示例位於netty-example-4.0.0.CR2.jar文件中,它們依賴於netty中的其他jar文件。

因此,您必須使用選項-cp指定您的類路徑才能使用它們。

java -cp netty-example-4.0.0.CR2.jar;netty-transport-4.0.0.CR2.jar;netty-common-4.0.0.CR2.jar;netty-buffer-4.0.0.CR2.jar io.netty.example.discard.DiscardServer 

希望這會有所幫助。