Writing Java Hello World for Google app engine
After hearing the buzz about java support in Google App Engine I decided to write a hello, world application and run it on Google App Engine.
Add Google plugin for Eclipse
The first step is to add the Google plugin in eclipse using Help menu > Software Updates… > Add site>. The site url is:
Create new project in eclipse
Create a new Web Application Project using File > New > Web Application Project
Specify your project name and package name. To keep the application simple, uncheck ‘use GWT’ and check ‘Use app engine’, then click ‘Finish’
This generates a working web application. The project structure looks like this:
Run your web application locally
Right click on your application and click on Run as… > Web Application.
This launches your web application locally on port 8080. You can access your application by typing the URL:
…. and your app says “Hello, World”!!
Create a Google App Engine account
Before you can deploy you hello world application to google app engine, you need to create an account on google app engine.
You can sign in with your existing google account.
When you try creating your first application you must verify Your Account by SMS. Simply enter your mobile phone number and type the code that you get in the SMS.
Select a unique application id in Google App Engine
Application id, like login name must be a unique name. You need to select a unique application id before proceeding. After selection the application id, http://<your application id>.appspot.com is reserved for your application.
Configure your eclipse application to use this application id
Right click on your eclipse project > Google > App engine settings. Enter your application id. Alternatively you can directly modify your appengine-web.xml file to add your application id.
Deploy your app to App Engine
Right click on your project > Google > Deploy to app engine.
You will be prompted for your user name and password. This is your google account information.
The above step should deploy your application to Google app engine. At the time of writing this feature is available to only the first 10000 users. If you are not one of the first 10,000 you will get the following message on the console.
java.io.IOException: Error posting to URL: http://appengine.google.com/api/appversion/... 400 Bad Request Invalid runtime specified. Unable to upload app: Error posting to URL: http://appengine.google.com/api/appversion/... 400 Bad Request Invalid runtime specified.
If you don’t have access to the java version yet, you can apply for permission here.
Try deploying the application again now. This time the deployment should be successful. You should see the following output on the console:
Creating staging directory Scanning for jsp files. Scanning files on local disk. Initiating update. Cloning 1 static files. Cloning 13 application files. Uploading 5 files. Uploaded 1 files. Uploaded 2 files. Uploaded 3 files. Uploaded 4 files. Uploaded 5 files. Deploying new version. Will check again in 1 seconds Closing update: new version is ready to start serving. Uploading index definitions. Deployment completed successfully
Access your live application on google app engine
Login to google app engine. You should see you application on the application overview page.
You should see version 1 of your newly deployed app. Click on this link. This link should be your http://<applicationid>.appspot.com, for example http://hellogoogapp.appspot.com/.
Your application page shows you a list of all available servlets.
Go ahead and click on the hello world servlet.
…. And finally, your google app says “Hello, world”. Here is the link to the app that I created: http://hellogoogapp.appspot.com/hellogoogleapp