Google App Engine For Java: An Introduction
A couple of days ago, Google announced that Java was now available to run on Google App Engine (GAE for short). Currently, they are only letting the first 10,000 developers who sign up for an account actually deploy a Java app:
April 2009: During this "early look" of Google App Engine for Java, the ability to upload Java applications to App Engine is reserved for a limited number of developer accounts. All users will be able to upload Java apps when we do a full release of Google App Engine for Java in the near future.
Fortunately, I was able to get an account and give it a test drive. Here's how to deploy a minimal web application without using the available Eclipse plugin:
- Install a Java SDK if you don't already have it installed. You will need Java version 5 or above.
- Download and install the Google App Engine Java SDK. I extracted the zip to my home directory and updated my system path to include ~/appengine-java-sdk-1.2.0/bin. Once this is done I can run the appcfg.sh script.
- Now that the GAE Java tools are installed, it's time to create a very simple Java web app. I decided to create an app with just a single JSP.
- Below is the entire directory layout with the usual WEB-INF/web.xml and the single index.jsp in the web root. You will also see two files specific to GAE for Java: appengine-web.xml and appengine-api-1.0-sdk-1.2.0.jar. These are essential in order to deploy your web app to GAE for Java./
- Below is an example of why my appengine-web.xml file looks like. There are several configuration elements which are documented here. Note that the application value here is angrygerbils which will be located at http://angrygerbils.appspot.com after I upload the app.
- For this app, my web.xml file is actually empty except for the web-app element:
- Now it's time to upload the app to GAE for Java using appcfg.sh. I created an exploded directory call angrygerbilsWeb and uploaded it with the following command:
appcfg.sh update angrygerbilsWeb
- You should see something like the following:
- Once complete, you can view the app in a browser.
- That's it! Note that are several limitations for running Java on GAE including not being able to spawn new threads, JRE Class White List, and certain frameworks such as Struts are simply not supported. You can read more about the limitations as well as the features.