Using Guava with GWT
guava, gwt
Solution
Guava isn't compatible with GWT 1.6. List.subList, in particular, is added to GWT in GWT 2. The earliest version that we fully supported is GWT 2.0.4
Problem
Could someone tell me what I need to do to enable Guava support in GWT. I have downloaded Guava R07 and in there there are the following two files: - guava-r07.jar - guava-r07-gwt.jar I have a few questions regarding this: - Where do these files go? I am guessing that the standard Jar is made available to my IDE for coding, and that both are made available to the GWT compiler for building the JavaScript? - Do I need to add all the .gwt.xml files from the -gwt.jar into my project's main gwt.xml file or only the portions I need? - There are other Jars on the trunk of the Guava&GWT project (ie not in the download, such as one for jsr305) which I think I may need, but I'm not sure. Sorry, normally I don't have trouble with this kind of thing, but I can't quite work out what goes where. FYI I'm using GWT 1.6 for the time being, but am hoping to move to 2 soon. If Guava isn't compatible with 1.6 that is not a problem. Update I have the following files in a folder called gwtlib: - guava-r07-gwt.jar - guava-r07.jar - jsr305-1.3.9.jar And my Ant script does the following: ``` <path id="project.class.path"> <fileset dir="gwtlibs" includes="guava-r07.jar"/> <fileset dir="gwtlibs" includes="guava-r07-gwt.jar"/> <fileset dir="gwtlibs" includes="jsr305-1.3.9.jar"/> <pathelement location="${gwt.sdk}/gwt-user.jar"/> <fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/> </path> <target name="gwtc"> <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler"> <classpath> <pathelement location="app"/> <path refid="project.class.path"/> </classpath> <jvmarg value="-Xmx256M"/> <arg value="-localWorkers"/> <arg value="2"/> <arg value="-war"/> <arg value="gwt-public"/> <arg value="Main"/> </java> </target> ``` Running the above command, I get the following errors: - Errors in 'jar:file:///project/gwtlibs/guava-r07-gwt.jar!/com/google/common/collect/Constraints.java' - Line 254: The method subList(int, int) is undefined for the type List Without the jsr jar on the classpath, I get the following errors: - The import javax.annotation cannot be resolved - Nullable cannot be resolved to a type Thanks Rich