How do I open the GWT samples in eclipse Helios and GWT 2.1.1?

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.


    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.


    The examples that come with GWT SDK were built in different ways. Some are Maven builds, others use Ant. Eclipse can handle these common builds directly, but you have to choose the right option.

    So, if you want to open the Expenses project in eclipse, you would look in the projects root directory (ie ../gwt2.4/samples/Expenses) where you'll find a file called pom.xml . That is a Maven build file. To import it into your Work space select:

  • File->Import...
  • Open Maven->Existing Maven Projects, and click on Next > button
  • Browse your file system til you reach the Expenses folder. Click on it and Select OK.
  • At this point it will show you the Projects in that directory in the Projects: area of the window...only one in this case: /pom.xml com.google.gwt.sample.expenses:...etc.

  • click on the checkbox for that project, Next>
  • Finally, it ask you to map plugins. You'll need to select in the drop down menu under Actions the required plugins (such as m2e).
  • In other project folders you may find a build.xml file instead. That's an Ant build file. To import that you do something similar, but different (of course!):

  • File->New->Project...
  • Open the Java folder and select "Java Project from Existing Ant Buildfile", Next >
  • Click the Browse button, dig through your directory to the project folder and select the build.xml file, and Open it.
  • Project name should fill in automatically, just select the declaration to use in the middle window and click Finish.

  • Since those tutorial only include the src and war directory, the idea remains to:

  • create a new project following this tutorial
  • remove any created class part of the example files which are automatically added (see Issue 1547)
  • Unfortunately the Google Plugin does not allow to created a new Web Application Project without creating template files. The template files are nice for the first try but annoying if you want to start from scratch with a new GWT application.

    替代文字

  • copy the src and war directory in place within the now empty project
  • 链接地址: http://www.djcxy.com/p/4150.html

    上一篇: gdb:内部错误设置断点

    下一篇: 如何在eclipse Helios和GWT 2.1.1中打开GWT示例?