Quickstart for App Engine Standard Environment for Java

This quickstart shows you how to create a small App Engine application that displays a short message.

Before you begin

Before running this sample, you must:

  1. Download and install the Java SE Development Kit (JDK):

    Download JDK

  2. Download Apache Maven version 3.3.9 or greater:

    Download Apache Maven

  3. Install and configure Maven for your local development environment.

Download the Hello World app

We've created a simple Hello World app for Java so you can quickly get a feel for deploying an app to Google Cloud Platform. Follow these steps to download Hello World to your local machine.

  1. Clone the Hello World sample app repository to your local machine:

    git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git
  2. Go to the directory that contains the sample code:

    cd java-docs-samples/appengine/helloworld
  3. In the resulting helloworld files you'll find the src directory for a package called com.example.appengine.helloworld that implements a simple HTTPServlet.

Alternatively, you can download the sample as a zip file and extract it.

Test the application

Test the application using the local development server, which is included with the App Engine SDK.

  1. From within your helloworld directory, run the following Maven command to compile your app and start the local development server:

    mvn appengine:devserver

    The development server is now listening for requests on port 8080.

  2. Visit http://localhost:8080/ in your web browser to see the app in action.

For more information about running the local development server, see the Java Development Server reference.

Make a change

You can leave the development server running while you develop your application. When you make a change, use the mvn clean package command to build and update your app.

  1. Try it now: Leave the development server running, then edit HelloServlet.java to change Hello, world to something else.
  2. Run mvn clean package, then reload http://localhost:8080/ to see the results.

Deploy your app

To deploy your app to App Engine, you will need to create a Cloud Platform project and App Engine application.

  1. Create a new Cloud Platform project and App Engine application using the Cloud Platform Console:

    Go to App Engine

    When prompted, select the region where you want your App Engine application located. After your App Engine application is created, the Dashboard opens.

  2. Open the src/main/webapp/WEB-INF/appengine-web.xml file in an editor and specify the project ID that you just created within the <application> elements. Tip: You can use the <version> elements in this file to also define a unique version ID for you app.

  3. Upload your application to App Engine by running the following command:

    mvn appengine:update
  4. Your app is now running in App Engine and ready to serve traffic at http://[YOUR_PROJECT_ID].appspot.com/.


You have completed this quickstart.

The full URL for your application is http://[YOUR_PROJECT_ID].appspot.com/. Optionally, you can purchase and use a top-level domain name for your app, or use one that you have already registered.

Clean up

To avoid incurring charges to your Cloud Platform project, you can delete your project to stop billing for all resources within the project.

  1. In the Cloud Platform Console, go to the Projects page.

    Go to the Projects page

  2. In the project list, select the project you want to delete and click Delete project. After selecting the checkbox next to the project name, click
      Delete project
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

What's next

Use a custom domain

You can serve your App Engine app using your own custom domain instead of appspot.com. For more information, see Using Custom Domains and SSL.

Hello World code review

Hello World is the simplest possible App Engine app: it contains only one service, and has only one version. This section describes each of the app files in detail.


This servlet responds to any request by sending a response containing the message Hello, world!.

public class HelloServlet extends HttpServlet {

  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    PrintWriter out = resp.getWriter();
    out.println("Hello, world");


The helloworld app uses Maven, which means you must specify a Project Object Model, or POM, which contains information about the project and configuration details used by Maven to build the project.

    <!-- for hot reload of the web application -->
      <!-- Parent POM defines ${appengine.sdk.version} (updates frequently). -->


You will also need to configure App Engine's behavior using appengine-web.xml. Use this file to specify a version for your application, and to enter the Project ID for your Google Cloud Platform project prior to uploading the application. For now it's okay to leave the file as it is.

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">


Java web applications use a deployment descriptor file to determine how URLs map to servlets, which URLs require authentication, and other information. This file is named web.xml, and resides in the app's WAR under the WEB-INF/ directory. web.xml is part of the servlet standard for web applications.

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

Learn the whole platform

Now that you know what it's like to develop and deploy App Engine apps, you can stretch out and see the rest of Google Cloud Platform. For a guided walkthrough that teaches you how to create an application that uses the entire platform, not just App Engine, check out our "Creating a Guestbook" quickstart in which you expand this simple application to become a fully-fledged Guestbook application that lets authenticated Google accounts post messages to a public page.

Learn more about App Engine standard environment

Here are some topics to help you to continue learning about App Engine.