Eclipse – How to open the GWT samples in eclipse Helios and GWT 2.1.1

eclipsegwtsample

What is the straight-forward way of importing one of the GWT samples in eclipse Helios + GWT 2.1.1. It seems like the content of the zip file doesn't contain any project files for eclipse.

I tried the following:

  • create a GWT project 'bla'
  • Delete the src ad war folder and
    replace it with the src and war
    folder from the sample
  • refresh the project in eclipse
  • hit 'run'

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

So I go to the run configuration and remove the path for the example projects from the arguments list. I also changed the name of hosted html page to the one in the sample. Hit 'run' and:

[ERROR] Invalid version number "2.0"
passed to external.gwtOnLoad(),
expected "2.1"; your hosted mode
bootstrap file may be out of date;

Now I need an out of date version of GWT to run these samples? What is going on, I just want to look at a sample to learn a new concept.

Best Answer

Reading the readme.txt in the GWT samples directory I came across a solution that works on Eclipse 3.7. Assuming you have ant installed on your machine, execute the following from the sample's directory:

ant eclipse.generate

This will generate both the .classpath and .project files needed to import the sample into Eclipse and run it.

Here the relevant excerpt from README.txt:

-- Option A: Import your project into Eclipse (recommended) --

If you use Eclipse, you can simply import the generated project into Eclipse. We've tested against Eclipse 3.4 and 3.5. Later versions will likely also work, earlier versions may not.

If the directory containing this file does not have a .classpath or .project file, generate them by running 'ant eclipse.generate'

In Eclipse, go to the File menu and choose:

File -> Import... -> Existing Projects into Workspace

Browse to the directory containing this file, select "Mail". Be sure to uncheck "Copy projects into workspace" if it is checked. Click Finish. You can now browse the project in Eclipse.

To launch your web app in GWT development mode, go to the Run menu and choose:

Run -> Open Debug Dialog...

Under Java Application, you should find a launch configuration
named "Mail". Select and click "Debug".

You can now use the built-in debugger to debug your web app in development mode.

In eclipse 3.7, instead of Run -> Open Debug Dialog..., its Run -> Debug Configurations. I got both the showcase and mail samples running following those commands. Should work for all of the other samples as well.

Related Topic