Using 3rd party libraries with GWT on client side?

余生颓废 提交于 2019-12-12 11:34:43

问题


I'm starting out with GWT and was wondering what libraries is it possible to use with GWT on the client side? Because GWT converts Java code into JavaScript, I can't really imagine all conversions to be possible if you are just using the client side.

Of course you wouldn't wanna use everything on client side in a real application, but I'm wondering what are the physical possibilities of the converter? Is there any kind of a list of supported libraries? How do you know if they can get converted to work with JavaScript? But I can imagine if you were to use something like Apache POI - it shouldn't work, right?

I might be missing some basic understanding there too I guess...


回答1:


These two links gives the jre compatibility provided with gwt. http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsCompatibility.html http://www.gwtproject.org/doc/latest/RefJreEmulation.html

Using other libraries with gwt

If you need to use third party libraries with gwt, you need to first convert that library into a gwt module. For creating a gwt module you need to put a modeulename.gwt.xml file in your library jar file. The xml file should contain source tag ( <source path="path" /> )to the package which needs to be gwt compatible. (You also need to include the java source files to the jar. Class files will not get compiled to javascript)

Then you have to inherit your module to your gwt project. For this add <inherits name="com.yourpackage.modeulename"/> to your projects gwt xml. (replace the package and module name as on your library)

Now you can compile the library into javascript.(Make sure that your library is not using any gwt incompatible codes like external libraries, incompatible jre codes etc. Or you can convert that libraries into get modules)

For further reference :GWT oraganising projects




回答2:


The page you are looking for in the GWT documentation is http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsCompatibility.html

There's a (generated) list of emulated Java Runtime classes and methods at http://www.gwtproject.org/doc/latest/RefJreEmulation.html (not always up-to-date, but it's a start)



来源:https://stackoverflow.com/questions/25728158/using-3rd-party-libraries-with-gwt-on-client-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!