开发者

Google Web Toolkit - how to add an external .jar package

How do we add an 开发者_Go百科external .jar package in Google Web Toolkit (GWT)? I have followed the steps

1) added the .jar in classpath

2) added <inherits name='org.scribe.model' /> in my test.gwt.xml

I get this error:

Loading inherited module 'org.scribe.model'

[ERROR] Unable to find 'org/scribe/model.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

[ERROR] Line 8: Unexpected exception while processing element 'inherits'

However, I have found from many sources that you need the source files to compile the client side gwt. My question is what if one cannot get a source file of the .jar package? What is the workaround?

Thanks in advance.


If it is a GWT module it is packaged with sources. Check the jar Java files should be in it.

There are two ways to use a 3rd party dependency in your GWT application.

  • It is either a GWT module already which contains a module xml file along with the source files. In this case you just refer to it using inherits.
  • Or it is some regular 3rd party dependency in this case you need the source code and you also have to play with the package names since GWT requires source code to be under client package. Even you do so since the artifact is not developed GWT in mind, it might most likely contain code that is not allowed by GWT, e.g. you cannot use Threads in GWT.


There is no workaround. You need source files.. At least you can decompile class files..


My suggestion would be to handle intense logic on server side (within server package)

On the server side , you can use classes that are not supported by GWT front-end (classes in client package).

E.g When I tried to use BufferedReader in client, I got exceptions, I then moved it to server package and retuned the result. The same was for RE which didn't work in client code too.

Keep your client code as simple as possible. Hope this helps.

Cheers PB

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜