2010-03-03 124 views
6

我將使用jacob.jar。但問題是jacob jar文件沒有xxx.gwt.xml文件。所以我無法將其繼承到我的項目xml文件中。如何添加外部JAR文件到GWT項目

如何解決此問題?或GWT不允許我們添加外部JAR文件?

回答

-6

您可以使用外部罐子,如果我理解你糾正你不需要把它插入到xxx.gwt.xml文件。例如 - 我使用maven來構建我的項目,外部jar被定義爲pom.xml中的依賴項。

3

如果你打算使用任何包含在JAR中的類,你需要的源或xxx.gwt.xml。不過,您可以在服務器端使用該jar而不會出現問題。有關爲jar類創建xxx.gwt.xml的示例,請參閱http://www.vogella.com/articles/GWTModules/article.html

+0

最後,他將需要源代碼和一個gwt.xml文件。如果他只有源代碼,他可以創建一個gwt.xml。 – 2010-04-13 20:22:52

3

你不必繼承xxx.gwt.xml如果你想使用服務器端代碼庫(或GWT發電機)。如果你想在客戶端代碼中使用庫,你還必須繼承xxx.gwt.xml,如果庫沒有這個GWT xml文件,它不可能與GWT一起工作(它不會是可編譯的gwt JS編譯器)。 無論如何,如果你願意,你可以創建自己的xxx.gwt.xml。

彼得

0

下面是我的測試環境中,我只需打開一個新的GWT項目,並在它的服務器端代碼進行修改。我在此代碼中添加了: /** * RPC服務的服務器端實現。 */ @SuppressWarnings( 「串行」) 公共類GreetingServiceImpl擴展RemoteServiceServlet實現 GreetingService的{

public String greetServer(String input) { 
    ActiveXComponent xl = new ActiveXComponent("Excel.Application"); 
    Object xlo = xl.getObject(); 

編譯後沒有錯誤。

但是當我在調試模式下運行時, 「ActiveXComponent XL =新ActiveXComponent(」 Excel.Application 「)之後;」。

然後顯示此錯誤消息: : 「ava.lang.UnsatisfiedLinkError:沒有雅各布的java.library.path」: 戰爭\ WEB-INF \ lib中\雅各

我的jar文件放在下.JAR

5

我沒有解決這個問題。因爲我發現另一個GWT庫可以滿足我的要求。 但我從GWT論壇得到了一個建議。我希望它能幫助你!請看下面:

Blockquote The library you are trying to use is intended for running in a java VM, not a browser's javascript engine. You need either a javascript library to wrap with JSNI, or a java library that meets the requirements below. Google openid gwt and you'll see how people have been able to use openid with gwt.

Blockquote The GWT java->javascript compiler used to create client browser code does not translate any arbitrary Java library for you. For one, it is limited to emulating a subset of the java JRE, so any library may only use that subset of java JRE functionality. For two, it works on the java source code, so any library you expect to use on the client side must be packaged to include its source. There are plenty of libraries people have packaged for use on the GWT client side, but they are packaged using GWT's packaging standard with an xml description file, must include the source, and use the restricted subset of the JRE. http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsCompatibility.html

0

Guaz:

JACOB使用JNI來完成其工作。所以JACOB的java類需要加載jacob.dll。 JACOB文檔在http://danadler.com/jacob/中說明了這一點(查找「下載」部分),它提到了dll。

該dll需要被放置在PATH變量所引用的目錄中。您還可以更改系統屬性java.library.path的值。這裏How to set the java.library.path from Eclipse是你如何在Eclipse中完成的。

相關問題