Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 629
Jan Avatar asked Jan 08 '11 03:01

Jan


2 Answers

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.

like image 142
iauns Avatar answered Nov 15 '22 11:11

iauns


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 (i.e. ../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:

  1. File->Import...
  2. Open Maven->Existing Maven Projects, and click on Next > button
  3. 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!):

  1. File->New->Project...
  2. Open the Java folder and select "Java Project from Existing Ant Buildfile", Next >
  3. Click the Browse button, dig through your directory to the project folder and select the build.xml file, and Open it.
  4. Project name should fill in automatically, just select the declaration to use in the middle window and click Finish.
like image 42
Marco A. Avatar answered Nov 15 '22 11:11

Marco A.