Netbeans:NetbeansGWTCreate
From Adapt
Setting up a NetBeans application to use the GWT
These instructions are valid for Netbeans 5.5 and GWT 1.3.3.
Unpack the GWT somewhere locally on your computer or export a copy from the repository. From the Netbeans menu, select =Tools->Library Manager=. Click on the =New Library= button and name the library =com.google.gwt=. Under the =Classpath= tab, add the following jar files: =gwt-servlet.jar=, =gwt-user.jar=, and either =gwt-dev-linux.jar=, =gwt-dev-windows.jar=, or =gwt-dev-mac.jar=. Under the =Javadoc= tab, add the =doc/javadoc= directory.
Create a new project in Netbeans and select a standard Java application but don't create a Main class. Under the project properties, add the GWT to the libraries. Create a root package for the application (e.g., =edu.umiacs.gwt.hello= for the sample Hello World application). In that package, create an xml file named ModuleName.gwt.xml, replacing ModuleName with the actual name of the module (e.g., HelloWorld.gwt.xml. Place the following in the xml file:
<?xml version="1.0" encoding="UTF-8"?> <module> <inherits name="com.google.gwt.user.User"/> </module>
Following Google's conventions, create a package under the root package named public which will hold all the HTML and web resources. *Note:* Netbeans will not allow you to create a package named public, so create the directory manually. Create an html file named ModuleName.html (e.g., HelloWorld.html), and put something simple inside like:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <h1>Hello World!</h1> </body> </html>
When we 'run' the project in Netbeans, it should launch the GWT shell. Override the target by placing the following in the build.xml file...
<target name="run" depends="init,compile"> <java classpath="${run.classpath}:${basedir}/build/classes:${basedir}/src" classname="com.google.gwt.dev.GWTShell" fork="true"> <arg value="-out"/> <arg path="${build.www.dir}/"/> <arg value="edu.umiacs.gwt.hello.HelloWorld/HelloWorld.html"/> </java> </target>
...and replace the last argument value with the correct module namespace and name of the html file.
Under Mac OS X, you will have to put an additional line inside the java ctag:
<target ...> <java ...> ... <jvmarg value="-XstartOnFirstThread"/> ... </java> </target>
Create a dummy main in a class to fake out Netbeans. Place this anywhere, call it anything, put in a new class or use an existing class--it doesn't matter. Example:
package edu.umiacs.gwt.hello; public class DummyMain { public static void main(String[] args) { throw new IllegalStateException("main called"); } }
Make sure to have main throw an exception or you will be confused in the event it actually gets invoked and nothing happens.
Now run the project and the GWT shell should appear with a browser window displaying the 'Hello World' message in total H1 glory.