Get an install of GWT up and running
During my growing experience with GWT i learned that it is better to create the project from scratch and import it into the IDE rather then using a IDE-wizard which often creates not all files you need. So let’s start bei downloading the Google Web Toolkit Archive and extract it. Open a shell (Windows-User run “cmd“) and navigate to the directory where you have extracted the GWT-archive. Run the following commands:
- webAppCreator.cmd -out MyProjectDirectory eu.jdevelop.gwt.MyApp
- i18nCreator.cmd -eclipse MyGwtProject -createMessages -out MyProjectDirectory eu.jdevelop.gwt.client.constants.i18n.MyLanguageConstants
So what have you done? You have created a GWT-Project and added support for Eclipse and internationalization (i18n).
Change into the created directory MyProjectDirectory and run the following commands to see that all is working:
- ant build
- ant hosted
Well done, now it is time to import this project into your favourite IDE.
Using NetBeans and GWT is not very difficult. Here i am using NetBeans v6.7.1 . First open in the menu “Tools“->”Plugins” and install the GWT4NB-Plugin.
Create a new “Web Application“-Project:
Choose a directory for it:
Select a Server:
Select the “Google Web Toolkit“-Framework in the next page and insert in the “GWT Module“-Textfield this: “eu.jdevelop.gwt.MyApp“. Notice the missing “client“-subpackage? It will be automatically created by the GWT4NB-Plugin.
After that you will see the created project from the GWT4NB-Plugin:
When you launch the application you can see that it is deployed into your previously selected Server:
Where is now the “hosted mode” ? To use it, only click on the Debug-Button in the menu. To use Ant-Targets you have to make some changes. First open the “project properties” and change the “web page folder” from “web” to “war“:
Open the file “build.xml“, located inside your GWT-Project (created in Create the Project-files):
Copy the content inside the “<project></project>“-tags and insert it into the “build.xml“-file, located in your NetBeans-Project directory:
Replace all appearances of “src” with “src/java“, because source files are located in a different directory.
You are now able to run the new ant targets “gwtc” and “hosted“:
The last step is the integration of i18n. Copy the whole “…gwt-windows-1.7.1\MyProjectDirectory\src\eu\jdevelop\gwt\client\constants\“-directory into the corresponding directory of your NetBeans-project.
Don’t forget to copy the file “MyLanguageConstants-i18n.cmd“, you need it to create the i18n-java-file! You have to open it in NetBeans and update the source-directory (there are two!) to “src/java“: