开发者

How to add external Jar file into GWT project

开发者 https://www.devze.com 2022-12-21 14:50 出处:网络
I am g开发者_StackOverflow社区oing to use jacob.jar. But the problem is the jacob jar file don\'t have xxx.gwt.xml file. So I not able to inherit it into my project xml file.

I am g开发者_StackOverflow社区oing to use jacob.jar. But the problem is the jacob jar file don't have xxx.gwt.xml file. So I not able to inherit it into my project xml file.

How to resolve this problem? or GWT not allow us to add external JAR file?


I not solved the problem. Because I found another GWT lib can fulfill my requirement. But I got one suggestion from GWT Forum. I hope it can help u! Please See Below :

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


You don't have to inherit xxx.gwt.xml if you want to use library on server side code (or in GWT generators). If you want to use library on client side code, you have to also inherit xxx.gwt.xml and if the library does not have this GWT xml file it will not probably work with GWT (it will not be compilable gwt JS compiler). Anyway you can create your own xxx.gwt.xml if you want.

Peter


You will need the source or a xxx.gwt.xml if you plan on using any of the classes included in the jar. You can use the jar without issue on the server side though. See http://www.vogella.com/articles/GWTModules/article.html on an example of creating the xxx.gwt.xml for the jar classes.


Below is my testing environment, I just simply open a new gwt project and modify on it server side code. I am added in this code: /** * The server side implementation of the RPC service. */ @SuppressWarnings("serial") public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService {

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

no error after compilation.

but when i run in debug mode, after the "ActiveXComponent xl = new ActiveXComponent("Excel.Application");".

Then it show this error msg: :"ava.lang.UnsatisfiedLinkError: no jacob in java.library.path"

my jar file is put under: war\WEB-INF\lib\jacob.jar


Guaz:

JACOB uses JNI to do its job. So JACOB's java classes needs to load jacob.dll. JACOB documentation states this in http://danadler.com/jacob/ (look for the "Download" section), it mentions the dll.

The dll needs to be placed in a directory referenced by the PATH variable. You can also change the value of the system property java.library.path. Here How to set the java.library.path from Eclipse is how you can do it in Eclipse.


You can use external jars and if i understand you correct you don't need to insert it into the xxx.gwt.xml file. For example - I'm using maven to build my project and the external jars are defined as dependencies in the pom.xml.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号