2010-03-03 116 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中完成的。

相关问题