tags:

views:

30

answers:

2

Hi,

I find it difficult to export classes from one project into JAR file, so that I could import it in another project.

How do I try?

I right-click on project in Package Explorer -> Export -> Java -> JAR file -> select all the packages I need. 'Export generated class files and resources' option is checked, other options are left unchecked. Then I click Finish.

When I import such generated .jar file into the dependent I encounter a list of errors:

The import pl.abc.xyz cannot be resolved

Xyz cannot be resolved to a type

It seems like the classes from the JAR file were not found by the compiler.

Please correct me, if I do it in a wrong way. Thanks.

+1  A: 

It seems that you need to include in jar also java source files from the client package (sometimes also shared package depending on your GWT module structure as defined in *.gwt.xml file).

The GWT compiler requires java source for the part which has to be compiled into Java Script, to be availabe as classpath resources along with compiled classes. It is simple to achieve with ant or maven build.

You can also check Export Java source files and resources when exporting, but it will add all the source code, not only the client part.

morisil
Actually, the point was to check 'Export Java source files and resources '. I suppose that GWT was unable to run the app in dev mode without java source in included jar. Thanks morisil.
rybz
A: 

Make sure you inherit the module in your .gwt.xml file. You want to inherit the .gwt.xml file from the GWT jar you are importing, for example:

<inherits name="com.example.youmodule.Name" />
AlbertoPL