How can I use org.apache.commons in GWT?

I am using GWT 2.5.0. I want to use some methods in org.apache.commons. GWT would like to get the source code for adding an external jar as well. So I downloaded the source and class files and merged them into a jar. This does not give any errors for some methods, but some org.apache classes reference another class outside of this package. Therefore it gives the following error:

[ERROR] [rmchecking] - Errors in 'org/apache/commons/lang/StringUtils.java'
[ERROR] [rmchecking] - Line 237: The method isWhitespace(char) is undefined for the type Character

      

Is there any package in gwt that provides the same functionality to this org.apache.commons? or how to use the same package in gwt?

+3


source to share


4 answers


This is not possible as StringUtils is regex based java

and GWT regex emulator is based on a javascript

. You will need to write it yourself



+5


source


You cannot use a third party jar that is not compatible with GWT. An example apache-commons .

ADVICE . They don't have a .gwt.xml file telling the GWT compiler that they have GWT compatible code.



However, you can fork it and make it its own gwt compatible lib from the general Apache. Example - http://code.google.com/p/gwt-commons-lang/

+11


source


I agree with SSR, although I wouldn't be surprised if there is some dirty debugging. It's worth noting that gwt-commons which is still in alpha, and google guava. I am using google Guava which has a similar target for apache commons. It even has some features that apache commons doesn't like Optionals. Guava has a fully functional version of gwt made by google that I use in my own project.

+2


source


I was able to convert most of Apache Commons Math 3.6.1 to compile with GWT 2.8.0, see https://github.com/murkle/commons-math/issues/1

+1


source







All Articles