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.

Wednesday, February 16, 2011

GWT 2.2 is out, supports HTML5

Google has released version 2.2 of GWT which supports some HTML5 features, namely the canvas element and the audio and video tag. This is great, I experimented a bit with the canvas element a couple of weeks ago by pulling in another library (GWT incubator), but I ended upp having trouble with some dependencies when I tried removing the server side code. I dunno if GWT 2.2 works better as I haven't tried it yet, but I hope so.

Read the full announcement here: http://googlewebtoolkit.blogspot.com/2011/02/google-plugin-for-eclipse-and-gwt-22.html

Sunday, January 16, 2011

Tips & Tricks

It's been a long time since posting on the blog. Here's some tips and tricks from my last GWT endeavors:
  • Installing Eclipse 3.6 (downloaded from eclipse.org) for 64-bit Linux (Ubuntu) may result in an error regarding the JVM: JVM exiting with error code 13. You have to start eclipse with the -vm option pointing to your JRE/JVM folder. For instance eclipse -vm /usr/lib/jvm/java-6-sun-1.6.0.22/jre/bin
  • When developing on your computer you probably want to do without SOP, Same origin policy, which means you can't load things from anything but the localhost. If you plan to use a PHP backend and have the server installed on localhost this isn't a problem, but if you want to load the PHP files from another server, then it is. In Firefox, go to Add-ons -> Extensions and choose Preferences for the GWT Developer Plugin and add your exceptions to the SOP.
If you can't find the plugin, just run the example GWT application in your browser and you should be directed to download it.

Friday, September 17, 2010

WindowBuilder released for free!

Ok, so this wasn't something I planned on doing for this blog, posting news that is. But this is a big one! Google has announced the release of GWT Designer and other related products, acquired from the company Instantiations. GWT Designer allows you to build GWT user interfaces visually with drag and drop and such. Pretty neat, huh? You can see a screen shot of it in the announcement and you can download it for your Eclipse version here.

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!).

Sunday, July 11, 2010

Googles page on GWT

So, it's been a while. I'm off to New York for two weeks in a couple of days, so I thought I'd make a post before leaving. This one is sort of a guide to Googles page on GWT. Not that it's really needed, it's easy to navigate, but just to make it easier for anyone thinking of beginning with GWT. The main page is linked in the right-hand side of the blog (press the toolbox), and below are some direct links to subpages that I personally found to be of use.

Is GWT for you?
You'll probably want to find out some more about GWT and if it is suitable for your needs. If you hit the Learn more link on the main page you'll get to an overview of features of GWT. It doesn't really say much, it's very generic and you'll not get the details out of it that you need to determine if it's suitable for you.

Most likely you have an idea of what kind of web app you're making. I found it useful to check out the examples page, and specifically the GWT Showcase, since it makes you start thinking of how to build the app. With the showcase of the widgets you'll get an understanding of how to structure your app, and you'll be able to check out some code as well.

Depending on what person you are, you'll decided to install it and try it out already or you'll want to get some more hands on examples. For me, I had to find out if it was at all possible to use PHP as a backend and I also wanted some hands on examples of that. The first time I visited the GWT page I had to resort to a Google search for that. We've covered the Learn more section on the left-hand side of the GWT page. If you think you're ready to install and try it out, you should check the Google Plugin for Eclipse and how to set up Eclipse (which is under Get started). I'll cover that in a later posting as well. It might seem redundant of me, but there are some specifics that I'd like to go over.

Anyway, for more information you can either check out the documentations under the Documentation section, or you can check out some tutorials under the Get started section. The difference here is that the tutorials are more hands on. I prefer the tutorials but there might not be one for your specific need. If there is one, you'll have to think less and can get down with the coding quicker. You should however browse through the documentation as well, since it explains how GWT works and what pieces are needed.

I'll just mention one last thing, which is essential when writing GWT apps, and that's the communication with a server. If you follow the link you'll see that there are a couple of alternatives mentioned. The first uses Java servlets ("Java on the backend"), and like I said in my earlier post this is not for me. Instead the choice falls on Retrieving JSON Data via HTTP:
If your application talks to a server that cannot host Java servlets, or one that already uses another data format like JSON or XML, you can make HTTP requests to retrieve the data.
You don't have to use JSON, of course, but there are methods in both PHP and Java to handle JSON which makes it a good choice. So I (or we) will make HTTP requests to a PHP page which outputs text in JSON format. First check out the page describing the process of getting JSON data via a servlet, and then check out the one using PHP instead.

Next up is a blog posting on the installation of Eclipse and GWT. By the way, did I mention that I'm a Linux user? Specifically Ubuntu. I don't know if I'll cover installing under Windows... It's probably covered in more detail elsewhere anyway.

Thursday, July 1, 2010

Read me first!

I've been looking a bit at GWT (that's short for Google Web Toolkit, but you probably know that if you found this blog) for awhile, experimenting a bit. I haven't really gotten anywhere, especially regarding useful code or best practices. I'm hoping this blog will keep me going at it in a more methodical way, and also keep whatever I learn stored in an accessible way. Perhaps it can be of use to someone else!

Why GWT?
Well, my development experience comes primarily from doing small desktop applications, mostly in Java. I know the basics of HTML and CSS, but not enough to do fancy web pages. Add to that the whole AJAX thingy, and you'll find it's not all that easy to take the step to the web. Enter GWT. It's like developing desktop applications, with a desktop feel, and you really don't need to know all that much about HTML and CSS (at least not to get started). You're programming in Java and compile to HTML and JavaScript, and it will run the same on all modern browsers. I think that's pretty neat!

Why start this blog?
My primary concern with GWT is that's it somewhat difficult to find books up to date with the latest version of GWT (as of this writing it's version 2.0 released in december 2009, with 2.1 around the corner), and suitable to my needs. Searching Amazon for GWT books, it seems there's one coming out later this summer that's covering GWT 2.0. The ones released the past year is covering older versions and they seem tied to Google App Engine and such, which I'm not interested in. Googles own page is shaping up with pretty decent tutorials, but when I first looked at GWT it was at version 1.5 or something, and the same couldn't be said back then. (I'm going to come back to Googles page on GWT in a later posting.) But still, if you're like me those tutorials doesn't really give you all that you need. So, hopefully this blog can be of use to someone, but if not then I have at least saved me knowledge for future use by myself!

Also, I'm a hobbyist when it comes to developing, so much of the pages I come across elsewhere on the web is a bit over my head. They're also generally focusing on "enterprise development", much like most of the books out there. By that I mean that more often than not they describe developing a GWT application with a servlet backend, or something along those lines. Personally I don't have my own server set up (at least not for outside access, I'm using a virtual server for development, which I'll be getting back to in a later posting I hope), and if you're a hobbyist like me you probably have one of the cheaper web hostings which don't let you deploy Java servlets. Instead, I have done some GWT experimenting together with PHP/MySQL (they always seem to come hand in hand, don't they?) and JSON. That's something that you'll find on most web hostings I believe.

In a nutshell
So in a nutshell you could say that the focus of this blog will be GWT development for personal use, as opposed to what I call enterprise use. This is not a "Learn how to program" blog, but rather a way for hobbyist programmers to find their way into GWT. I don't know if I'll be going into details all that much, you probably won't find much code here, at least not at first, but rather postings describing my practices. I'll be using Java (of course), some HTML and CSS, PHP and MySQL (perhaps some SQLite or flat file databases as well). I think I'll add a gadget to the page with upcoming blog posts...