Welcome

Disclaimer: I'm learning while I go, and I hope you will too! It should be pretty basic. I can't guarantee that what's presented here is the best practice.

Monday, August 23, 2010

Setting up GWT development

This is long overdue! I'll be going through the installation procedure of Sun's Java (well, Oracle's nowadays), Eclipse and the GWT plug-in. The instructions below is for Ubuntu 10.04, and should be fairly simple to adapt for other Linux distributions. If you're a Windows user, I'll briefly describe the steps/requirements in the end of this article.

So, what I normally do is, uninstalling the OpenJDK (if needed) and installing Sun/Oracle's Java Runetime Environment (JRE) and Software Development Kit (SDK) instead. The reason for this is that in my experience it just works better. This might just be a personally bias, so if you like you could just skip this step and proceed with the installation of Eclipse.


Installing the JRE, JDK and Eclipse in Ubuntu
Since Ubuntu 10.04 (or maybe 9.10) the Sun/Oracle's version is no longer in the default repositories, but rather moved to a Canonical Partner repository. All you need to do is add this repository, update your sources and install the packages needed.
  • Launch Software Sources from System -> Administration menu.
  • Under the Other tab, press Add and enter: deb http://archive.canonical.com/ubuntu lucid partner
  • Hit Add Source, Close and confirm the reloading of the sources.
That's it, the packages should show up in Synaptic now.
  • Launch Synaptic from System -> Administration menu.
  • Hit the Search button and search for "sun java" (choose only Name if you want a shorter list of packages).
  • Mark the packages sun-java-jre and sun-java-jdk for installation (a couple of others will be marked automatically).
  • I recommend uninstalling any OpenJDK packages that's not needed by other applications (on my test system OpenJDK packages weren't installed, but I'm not sure if this is due to running Ubuntu from a LiveCD).
  • Search for "eclipse" and mark the eclipse package for installation (in Ubuntu 10.04 this is version 3.5.2 which also is recommended by GWT Team as of this writing).
  • Hit Apply, go get some coffee and I'll see you in a couple of minutes! :-P
When the downloading and installing is finished, you should find Eclipse under the Applications -> Programming menu. Try launching it and see if it works! If it doesn't you could try launching it from the terminal and check for error messages. It could possibly be because of OpenJDK or maybe 64-bit architecture issues. Acctually, if you're running 64-bit Ubuntu you should probably install the packages ia32-sun-java6-bin as well...

Installing the GWT Plug-in in Eclipse
Ok, so now for installing the plug-in, this is much like repositories in Ubuntu (remember to check the GWT page on the Eclipse plug-in for updated instructions, for instance if you're using Eclipse 3.6 or later):
  • Choose Help -> Install new software... in Eclipse.
  • Enter http://dl.google.com/eclipse/plugin/3.5 and hit the Add button. Leave the Name field empty, and confirm.
  • You should see the entries Plugin and SDKs show up in the list below. Mark them and hit Next (twice) and confirm the license (you might have to accept some signatures later as well).
  • Get a coffee refill! Well, you've probably not even finished your first cup of java (ehehehe) so just roll your thumbs for a while :-)
  • Restart Eclipse
Trying it out
You should now have three new buttons in the toolbar. The first (a G+ on blue circular background) is for creating a new GWT project. The second (the red toolbox that I have in the links box to the right) is for compiling a project and the third (a jet engine with wings) is for deploying on Google App Engine. The third one is of no interest to me, and probably not for you either if you're hosting on your own server. Let's try out or installation:
  • Hit the first button (Create New Project)
  • Fill in the information required (Project name and Package) and confirm that the Use Google Web Toolkit checkbox is checked and that Use default SDK says GWT.
  • Hit the Run button (the one with the play icon on green circular background, but not the one with a little toolbox below it)
  • You should see a new tab called Develop created in the area below the code area. In that tabbed window there's an URL.
  • Copy the URL and paste it into Firefox. When you do there's a message about missing plugins for Firefox, just hit the download link and install the xpi file required. (I'm guessing the procedure is similar if you use Google Chrome.)
  • Restart Firefox and enjoy the little GWT project!
As you might have figured out, the new projects created contains a small code example. If you see it in your browser you should have succesfully installed Eclipse and the plug-ins required. You can start developing now! (I usually clean stuff out from the newly created project, but I'll get back to that in a later posting when I start coding for real.)

For Windows users
Ok, so Windows users should go to http://www.eclipse.org/downloads/ and download Eclipse IDE for Java Developers. It's now on version 3.6 but just change the version number in the step for installing the GWT plug-in and you should be alright (if you get download errors, check the instructions on the GWT page for manual download and install).

Actually, I might be going at this backwards, you should of course install the Java environment first (I hope you're one of those persons who read through the instructions before carrying them out! :-P). Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html and download the JDK (the JRE should be included in that download says the web page). Then install Eclipse and you should be able to follow the instructions for installing the plug-in (but remember to change the version number in the link) and trying it out. Post a comment if you have any problems, and preferably how you solved it (if you didn't I'll look into it!).

0 comments:

Post a Comment