The Java 8 / Jetty 9.3 Runtime

The Java 8 / Jetty 9 runtime uses Open JDK 8 and Jetty9 with Servlet 3.1.


Before you start developing, follow these steps:

For Java development, we recommend you use either the Apache Maven or Gradle build system to create Web Archive (WAR) files for deployment.

Organizing your files

Your development file hierarchy should look like this:


You'll need to define an app.yaml file that looks like this:

runtime: java
vm: true

- url: /.*
  script: this field is required, but ignored
  secure: always

Other app.yaml settings are described in Using app.yaml.

pom.xml is for configuring Maven and build.gradle is for confiuring Gradle.

Optional files

The additional configuration files index.yaml, cron.yaml, and dispatch.yaml are optional. They are placed at the top level of MyDir. If you use any these files they must be deployed separately with the gcloud app deploy command.

web.xml is optional and is needed only if you are not using Servlet 3.x annotations.

You can place static web content in your webapp/ directory as well as JavaServer pages. Jetty 9.3 which App Engine flexible environment uses as its Servlet container uses Apache Jasper as the default JSP implementation and includes JSTL taglibs.

The Dockerfile file is optional and is used if you want to customize the Java runtime.

Environment variables

The Java 8/Jetty 9 runtime is aware of these environment variables, all are optional:

  • JAVA_OPTS Optional extra java command options
  • DBG_ENABLE Used to run the jdpa debugger locally, and Stackdriver Debugger for deployed apps
  • DBG_PORT Used for local debugging on an image

Use the env_variables key in the app.yaml file to set environment variables:


Local testing

When you are testing in your local environment, you might prefer to use emulated Google cloud services, rather than remote Google cloud services. There are emulators for Cloud Datastore, Cloud PubSub, and Cloud Bigtable. Use the gcloud command to start them before you run your app:

gcloud beta emulators datastore start
gcloud beta emulators pubsub start
gcloud beta emulators bigtable start


Add these lines in your maven pom.xml file to add the Jetty9 Maven Plugin:


To run your app locally, use the Maven command:

mvn jetty:run-exploded


Follow the Gradle - creating a new project instructions to add the Gretty Gradle plugin to your build.gradle, and use the command:

gradle jettyRun

Deploying your app

If you need to initialize the Google Cloud SDK, do so with the command:

gcloud init

If you are using any of the optional configuration files (index.yaml, cron.yaml, and dispatch.yaml) be sure to deploy them separately with the gcloud command, for example:

gcloud app deploy cron.yaml


mvn appengine:deploy


gradle appengineDeploy

Customizing the Java 8 / Jetty 9.3 runtime

You don't need a Dockerfile to deploy your app into the Java 8/Jetty 9.3 runtime. If your app requires additional configuration, you can explicitly provide a Dockerfile to customize the Java runtime. The Dockerfile must include the base image You can add additional directives to the Dockerfile to customize the Java runtime. See Building Custom Runtimes.

Your Dockerfile should begin like this:

ADD test-webapp-1.0-SNAPSHOT.war $JETTY_BASE/webapps/root.war
RUN java -jar $JETTY_HOME/start.jar --approve-all-licenses --add-to-startd=jmx,stats,hawtio \
 && chown -R jetty:jetty $JETTY_BASE

In this case, test-webapp-1.0-SNAPSHOT.war is the name of the built WAR file in your target/ directory (maven), or build/staged-app/ (gradle).

Send feedback about...

App Engine flexible environment for Java docs