Configuring your app with app.yaml

Note: SomeJava runtimes have reachedend of support. You cannot re-deployversions that use runtimes after their end of support date. We recommend thatyouupgrade your appto use the latest version of Java.

An App Engine app is configured using anapp.yamlfile, that contains CPU, memory, network and disk resources, scaling, and othergeneral settings including environment variables.

Aboutapp.yaml files

You can specify the runtime configuration for your Java app,including versions and URLs, in theapp.yaml file. This file acts as a deployment descriptor of a specificserviceversion.

You must first create theapp.yaml file for thedefault service of your appbefore you can create and deployapp.yaml files for additional services.

The followingapp.yaml sample demonstrates how to configure your app forthelatest Java version.For more information about using supported Java runtimes, see theJava runtime.

runtime:javaenv:flexruntime_config:operating_system:"ubuntu24"runtime_version:"25"handlers:-url:/.*script:this field is required, but ignoredmanual_scaling:instances:1

Depending on the complexity of your app's service, you might only need to definea few elements in the correspondingapp.yaml file. The following exampledemonstrates what a simple Java app might require in theflexible environment:

You can specify a unique name for yourapp.yaml files, but then you mustspecify the file name with thedeploymentcommandas well. For example, if you name yourapp.yaml fileservice-name-app.yamlorapp.flexible.yaml, then you must deploy your app using either:

gcloudappdeployservice-name-app.yamlgcloudappdeployapp.flexible.yaml
To learn more about structuring multiple services andapp.yaml files in yourapp, seeStructuring web services.

All configuration elements

For a complete list of all the supported elements in this configuration file,see theapp.yaml reference.

Enabling Java Virtual Machine metrics collection

You can configure App Engine flexible environment for Java to collect common metrics for JavaVirtual Machine (JVM) processes. The metrics are collected using the sameJVM monitoring pluginthatCloud Monitoring uses. To view the full list of metricsfor App Engine, see theGoogle Cloud metrics guide.

If you want to collect these JVM metrics for your app:

  • appengine.googleapis.com/flex/instance/jvm/gc/count
  • appengine.googleapis.com/flex/instance/jvm/gc/time

you'll need to set the followingJMX systemproperties in the environment variables in yourapp.yaml and deploy your app.

JAVA_USER_OPTS:"-Djava.rmi.server.hostname=172.17.0.1-Dcom.sun.management.jmxremote.port=10403-Dcom.sun.management.jmxremote.rmi.port=10403-Dcom.sun.management.jmxremote.local.only=false-Dcom.sun.management.jmxremote.authenticate=false-Dcom.sun.management.jmxremote.ssl=false"
Note: The172.17.0.1 IP enables your container to connect to theJVM monitoring plugin running in App Engine flexible environment. Port 10403 is the reservedJMX_PORT on the app container which the monitoring plugin connects to.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.