blob: a9c9baa4fc23f1e585c30551be640c9f77e06c05 [file] [log] [blame]
gwt.team.bruce4b500c12007-08-15 22:29:15 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3 <head>
gwt.mirrorbot@gmail.comd54a4bd2010-06-07 19:20:31 +00004
gwt.team.bruce4b500c12007-08-15 22:29:15 +00005<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
6<title>Google Web Toolkit - Getting Started Guide</title>
gwt.mirrorbot@gmail.comd54a4bd2010-06-07 19:20:31 +00007<link href="../css/base.css" rel="stylesheet" type="text/css">
8<link href="./doc.css" rel="stylesheet" type="text/css">
9<link href="../css/print.css" rel="stylesheet" media="print" type="text/css">
gwt.team.bruce4b500c12007-08-15 22:29:15 +000010
11<style type="text/css">
12
13#footer .text {
14 padding-top: 5px;
15}
16
17.documentation {
18 margin-left: 0.25in;
19}
20
21.documentation h1 {
22 margin-left: -0.25in;
23}
24
25.documentation h2 {
26 margin-left: -0.25in;
27 margin-top: 1.5em;
28}
29
30.documentation h3 {
31 margin-left: -0.125in;
32}
33
34.documentation ul.toc {
35 margin: 0;
36 padding: 0;
37 margin-left: 2em;
38}
39
40</style>
41
42 <style type="text/css">
43
44 ol.instructions {
45 margin: 0;
46 padding: 0;
47 margin-left: 2em;
48 }
49
50 .instructions .header {
51 font-weight: bold;
52 }
53
54 .instructions li {
55 margin-bottom: 1em;
56 }
57
58 div.screenshot {
59 text-align: center;
60 margin: 1em;
61 }
62
63 </style>
64 </head>
65 <body>
66
67<div id="gaia">
68 &nbsp;
69</div>
70
71<div id="header">
gwt.mirrorbot@gmail.comd54a4bd2010-06-07 19:20:31 +000072 <div id="logo"><a href="http://code.google.com/"><img src="http://code.google.com/images/code_sm.png" alt="Google"/></a></div>
gwt.team.bruce4b500c12007-08-15 22:29:15 +000073 <div id="title">
74 Google Web Toolkit
75 </div>
76 <div id="breadcrumbs">
77
78 <span class="item"><a href="http://code.google.com">Google Code Home</a></span> &gt;
79
80<span class="item"><a href="http://code.google.com/webtoolkit">Google Web Toolkit</a></span> &gt;
81<span class="item"><a href="">Getting Started Guide</a></span>
82
83 </div>
84</div>
85
86<div id="side" dir="ltr">
87 <div id="menu">
88
89
90<h4><a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a></h4>
91<ul>
92 <li><a href="http://code.google.com/webtoolkit/download.html">Download GWT</a></li>
93</ul>
94<ul>
95 <li><a href="http://code.google.com/webtoolkit/overview.html">Product Overview</a></li>
96 <li><a href="">Getting Started Guide</a></li>
97 <li><a href="http://code.google.com/webtoolkit/documentation/examples/">Example Projects</a></li>
98</ul>
99<ul>
100 <li><a href="./com.google.gwt.doc.DeveloperGuide.html">Developer Guide</a></li>
101 <li><a href="./gwt.html">Class Reference</a></li>
102 <li><a href="http://code.google.com/p/google-web-toolkit/issues/list">Issue Tracking</a></li>
103 <li><a href="http://groups.google.com/group/Google-Web-Toolkit">Developer Forum</a></li>
104</ul>
105<ul>
106 <li><a href="http://googlewebtoolkit.blogspot.com/">GWT Blog</a></li>
107 <li><a href="http://code.google.com/webtoolkit/faq.html">GWT FAQ</a></li>
108 <li><a href="http://code.google.com/webtoolkit/makinggwtbetter.html">Making GWT Better</a></li>
109</ul>
110<ul>
111 <li><a href="http://code.google.com/webtoolkit/thirdparty.html">Third Party Tools</a></li>
112</ul>
113
114 </div>
115
116 <div id="search">
117 <form id="searchbox_015986126177484454297:pfmwlvdl42y" action="http://www.google.com/cse">
118 <input type="hidden" name="cx" value="015986126177484454297:pfmwlvdl42y" />
119 <input type="hidden" name="cof" value="FORID:0" />
120 <div class="header">Search Google Code:</div>
121 <input name="q" type="text" size="20" />
122 <input type="submit" name="sa" value="Search" /><br/>
123 </form>
124 <script type="text/javascript" src="http://google.com/coop/cse/brand?form=searchbox_015986126177484454297:pfmwlvdl42y"></script>
125 </div>
126
127</div>
128
129
130<script type="text/javascript">
131//<![CDATA[
132
133function walk(element, condition, operation) {
134 if (!element) return;
135 if (condition(element)) {
136 operation(element);
137 return;
138 }
139 for (var e = element.firstChild; e != null; e = e.nextSibling) {
140 walk(e, condition, operation);
141 }
142}
143
144function isCurrentLink(e) {
145 return e.tagName == "A" && e.href == window.location.href;
146}
147
148function makeSelected(e) {
149 e.className = "selected";
150}
151
152walk(document.getElementById("breadcrumbs"), isCurrentLink, makeSelected);
153walk(document.getElementById("menu"), isCurrentLink, makeSelected);
154
155//]]>
156</script>
157
158<div id="body">
159
160
161
162<div class="documentation">
163
164<h1>Google Web Toolkit Getting Started Guide</h1>
165
166<h2>Table of Contents</h2>
167
168<ul class="toc">
169 <li><a href="#Install">Installing Google Web Toolkit</a></li>
170 <li><a href="#Sample">Building a Sample Application</a></li>
171 <li><a href="#New">Creating an Application from Scratch (without Eclipse)</a></li>
172 <li><a href="#NewEclipse">Creating an Application from Scratch (with Eclipse)</a></li>
173</ul>
174
175
176<a name="Install"></a>
177<h2>Installing Google Web Toolkit</h2>
178
179<ol class="instructions">
180 <li>
181 <div class="header">Install the Java SDK.</div>
182 <div class="details">If you don't have a recent version of the Java SDK installed, download and install <a href="http://java.sun.com/javase/downloads/" rel="nofollow">Sun Java Standard Edition SDK</a>.</div>
183 </li>
184 <li>
185 <div class="header">Download Google Web Toolkit.</div>
186 <div class="details">Download the <a href="http://code.google.com/webtoolkit/download.html">Google Web Toolkit package</a> for your operating system.</div>
187 </li>
188 <li>
189 <div class="header">Unzip the Google Web Toolkit package.</div>
190 <div class="details">On Windows, extract the files from <code>gwt-windows-@GWT_VERSION@.zip</code> with a program like <a
191href="http://www.winzip.com/" rel="nofollow">WinZip</a>. On Mac and Linux, you can
192unpack the package with a command like <pre class="code">tar xvzf gwt-mac-@GWT_VERSION@.tar.gz</pre></div>
193 </li>
194 <li>
195 <div class="header">Done! Start using Google Web Toolkit.</div>
196 <div class="details">GWT doesn't have an installer application. All the files you need to run and use GWT are located in the extracted directory. The main application you'll need to use GWT is <code>applicationCreator</code>, which is <a href="#New">described below</a>. It may be easiest to start out by building one of the <a href="#Sample">sample applications</a> shipped with GWT.</div>
197 </li>
198</ol>
199
200
201
202<a name="Sample"></a>
203<h2>Building a Sample Application</h2>
204
205<p>All the sample applications are in the <code>samples/</code> directory in your GWT package. Each sample has a script you can run to start it in <a href="./com.google.gwt.doc.DeveloperGuide.Fundamentals.HostedMode.html">hosted mode</a> and a script you can use to compile it into JavaScript and HTML to run it <a href="com.google.gwt.doc.DeveloperGuide.Fundamentals.WebMode.html">web mode</a>.</p>
206
207<h3>Running in Hosted Mode</h3>
208
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000209<p>To run the Mail sample in <a href="./com.google.gwt.doc.DeveloperGuide.Fundamentals.HostedMode.html">hosted mode</a>, navigate to the <code>samples/Mail/</code> directory and run the <code>Mail-shell</code> script. This will open the GWT browser with the Mail application running inside:</p>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000210
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000211<div class="screenshot"><img src="./mail-hosted.png" alt="Screenshot"/></div>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000212
213<p>Since you're running in <a href="./com.google.gwt.doc.DeveloperGuide.Fundamentals.HostedMode.html">hosted mode</a>, the application is running in the Java Virtual Machine (JVM). This is typically the mode you'll use to debug your applications.</p>
214
215<h3>Running in Web Mode</h3>
216
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000217<p>To run the application in <a href="./com.google.gwt.doc.DeveloperGuide.Fundamentals.WebMode.html">web mode</a>, compile the application by running the <code>Mail-compile</code> script. The GWT compiler will generate a number of JavaScript and HTML files from the Mail Java source code in the <code>www/</code> subdirectory. To see the application, open the file <code>www/com.google.gwt.sample.mail.Mail/Mail.html</code> in your favorite web browser.</p>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000218
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000219<div class="screenshot"><img src="./mail-web.png" alt="Screenshot"/></div>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000220
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000221<p>Since you've compiled the project, you're now running pure JavaScript and HTML that should work in IE, Firefox, or Safari. If you were to deploy the Mail example project in production, you would distribute the files in your <code>www/com.google.com.google.gwt.sample.mail.Mail/</code> directory to your web servers.</p>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000222
223<h3>Make a Few Changes</h3>
224
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000225<p>The source code for Mail sample is in the <code>src/</code> subdirectory. Try closing your browser windows, and open the file
226<code>src/com/google/gwt/sample/mail/client/Shortcuts.java</code> in a text editor. Line 55 of the file adds a new &quot;Tasks&quot;
227section to the main StackPanel on the left side of the application:</p>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000228
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000229<pre class="code">add(images, new Tasks(), images.tasksgroup(), &quot;Tasks&quot;);</pre>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000230
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000231<p>Change the string from <code>&quot;Tasks&quot;</code> to <code>&quot;To-Do List&quot;</code>:</p>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000232
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000233<pre class="code">add(images, new Tasks(), images.tasksgroup(), &quot;To-Do List&quot;);</pre>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000234
235<p>Now, save the file and simply click "Refresh" in the hosted mode application to see your recent change (if you previously closed
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000236hosted mode, go ahead and re-run the <code>Mail-shell</code> script). The second item in the main StackPanel should now say
237&quot;To-Do List&quot; instead of &quot;Tasks&quot;:</p>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000238
jlabanca@google.com8b035a82008-04-17 15:39:58 +0000239<div class="screenshot"><img src="./mail-modified.png" alt="Screenshot" style="border: 1px solid silver"/></div>
gwt.team.bruce4b500c12007-08-15 22:29:15 +0000240
241<a name="New"></a>
242<h2>Creating an Application from Scratch (without Eclipse)</h2>
243
244<p>GWT ships with a command line utility called <code>applicationCreator</code> that automatically generates all the files you'll need in order to start a GWT project. It can also generate <a href="http://www.eclipse.org/" rel="nofollow">Eclipse</a> project files and launch config files for easy hosted mode debugging, as <a href="#NewEclipse">described below</a>.</p>
245
246<p>Based on the <a href="./com.google.gwt.doc.DeveloperGuide.Fundamentals.ProjectStructure.html">recommended GWT project structure</a>, your main GWT application class should be in a subpackage <code>client</code>. You can create a new application called MyApplication with the command:</p>
247
248<pre class="code">applicationCreator com.mycompany.client.MyApplication</pre>
249
250<p>The <code>applicationCreator</code> script will generate a number of files in <code>src/com/mycompany/</code>, including some basic &quot;Hello, world&quot; functionality in the class <code>src/com/mycompany/client/MyApplication.java</code>. The script also generates a <a href="overview.html#Modes">hosted mode</a> launch script called <code>MyApplication-shell</code> and a compilation script called <code>MyApplication-compile</code>, just like the <a href="#Sample">sample application</a> above.</p>
251
252<p>To run your newly created application in hosted mode, run the <code>MyApplication-shell</code> script:</p>
253
254<div class="screenshot"><img src="./myapplication-hosted.jpg" alt="Screenshot"/></div>
255
256<p>Try editing the files <code>src/com/mycompany/client/MyApplication.java</code> and <code>src/com/mycompany/public/MyApplication.html</code> to see how it changes your application.</p>
257
258
259<a name="NewEclipse"></a>
260<h2>Creating an Application from Scratch (with Eclipse)</h2>
261
262<p>GWT includes a command line utility called <code>applicationCreator</code> that automatically generates all the files you'll need in order to start a GWT project. It can also generate <a href="http://www.eclipse.org/" rel="nofollow">Eclipse</a> project files and launch config files for easy hosted mode debugging. To generate an Eclipse project for a new application, first use the <code>projectCreator</code> script to generate a shell Eclipse project for your application:</p>
263
264<pre class="code">projectCreator -eclipse MyProject</pre>
265
266<p>Then generate your GWT application as <a href="#New">described above</a>, but with an additional <code>-eclipse</code> flag specifying the name of your Eclipse project:</p>
267
268<pre class="code">applicationCreator -eclipse MyProject com.mycompany.client.MyApplication</pre>
269
270<p>When you're done with these scripts, in addition to the <code>MyApplication-shell</code> and <code>MyApplication-compile</code> scripts, you should see <code>.project</code>, <code>.classpath</code>, and <code>MyApplication.launch</code> files in your current directory.</p>
271
272<p>To open your project in Eclipse, launch Eclipse and click the File -> Import menu. Choose &quot;Existing Projects into Workspace&quot; in the first screen of the wizard, and enter the directory in which you genetrated the <code>.project</code> file in the next screen of the wizard. When you are complete, you should see your GWT project loaded into your Eclipse workspace:</p>
273
274<div class="screenshot"><img src="./myapplication-eclipse.jpg" alt="Screenshot" style="border: 1px solid silver"/></div>
275
276<p>Just click the green &quot;Run&quot; button at the top of the window to start your project in <a href="./com.google.gwt.doc.DeveloperGuide.Fundamentals.HostedMode.html">hosted mode</a>.</p>
277
278</div>
279
280
281
282
283
284</div>
285
286<div id="footer" dir="ltr">
287
288 <div class="text">
289
290
291<div style="margin-bottom: 0.5em">Java&trade; is a trademark of Sun Microsystems.</div>
292<div style="margin-bottom:0.5em">
293 &copy;2007 Google -
294 <a href="http://www.google.com/">Google Home</a> -
295 <a href="http://www.google.com/jobs/">We're Hiring</a> -
296 <a href="/webtoolkit/terms.html">Terms and Conditions</a> -
297 <a href="http://groups.google.com/group/Google-Web-Toolkit">Developer Forum</a>
298</div>
299<div id="notice" style="text-align: center; border: 1em 0em 1em 0em">
300 Except as otherwise <a
301 href="http://code.google.com/policies.html#restrictions">noted</a>,
302 the content of this page is licensed under the <a rel="license"
303 href="http://creativecommons.org/licenses/by/2.5/">Creative Commons
304 Attribution 2.5 License</a>.
305<!-- <rdf:RDF xmlns="http://web.resource.org/cc/"
306 xmlns:dc="http://purl.org/dc/elements/1.1/"
307 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
308 <Work rdf:about="">
309 <license rdf:resource="http://creativecommons.org/licenses/by/2.5/" />
310 </Work>
311 <License rdf:about="http://creativecommons.org/licenses/by/2.5/">
312 <permits rdf:resource="http://web.resource.org/cc/Reproduction"/>
313 <permits rdf:resource="http://web.resource.org/cc/Distribution"/>
314 <requires rdf:resource="http://web.resource.org/cc/Notice"/>
315 <requires rdf:resource="http://web.resource.org/cc/Attribution"/>
316 <permits rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
317 </License>
318</rdf:RDF> -->
319</div>
320
321
322
323
324 </div>
325</div>
326
327<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
328</script>
329
330
331<script type="text/javascript">
332 _uacct="UA-18071-1"; // code.google.com site-wide tracking
333 _uanchor=1;
334 _uff=0;
335 urchinTracker();
336</script>
337
338
339 </body>
340</html>