<br />

<br />

<br />

<br />

<br />

<br />


> [!NOTE]
> **Note:** Some [Java runtimes](https://docs.cloud.google.com/appengine/docs/flexible/lifecycle/support-schedule#java) have reached [end of support](https://docs.cloud.google.com/appengine/docs/flexible/lifecycle/runtime-lifecycle#end_of_support). You cannot re-deploy versions that use runtimes after their end of support date. We recommend that you [upgrade your app](https://docs.cloud.google.com/appengine/docs/flexible/java/runtime#newversions) to use the latest version of Java.

<br />


An App Engine app is configured using an `app.yaml`
file, that contains CPU, memory, network and disk resources, scaling, and other
general settings including environment variables.


## About `app.yaml` files

<br />

You can specify the runtime configuration for your Java app, including versions and URLs, in the `app.yaml` file. This file acts as a deployment descriptor of a specific [service](https://docs.cloud.google.com/appengine/docs/flexible/an-overview-of-app-engine) version.

<br />


You must first create the `app.yaml` file for the `default` service of your app
before you can create and deploy `app.yaml` files for additional services.


The following `app.yaml` sample demonstrates how to configure your app for
the [latest Java version](https://docs.cloud.google.com/appengine/docs/flexible/lifecycle/support-schedule#java).
For more information about using supported Java runtimes, see the
[Java runtime](https://docs.cloud.google.com/appengine/docs/flexible/java/runtime).

    runtime: java
    env: flex
    runtime_config:
      operating_system: "ubuntu24"
      runtime_version: "25"

    manual_scaling:
      instances: 1


Depending on the complexity of your app's service, you might only need to define
a few elements in the corresponding `app.yaml` file. The following example
demonstrates what a simple Java app might require in the
flexible environment:


You can specify a unique name for your `app.yaml` files, but then you must
specify the file name with the [deployment
command](https://docs.cloud.google.com/appengine/docs/flexible/testing-and-deploying-your-app)
as well. For example, if you name your `app.yaml` file `service-name-app.yaml`
or `app.flexible.yaml`, then you must deploy your app using either:

    gcloud app deploy service-name-app.yaml
    gcloud app deploy app.flexible.yaml

To learn more about structuring multiple services and `app.yaml` files in your app, see [Structuring web services](https://docs.cloud.google.com/appengine/docs/flexible/configuration-files).

<br />

## All configuration elements

For a complete list of all the supported elements in this configuration file,
see the
[`app.yaml` reference](https://docs.cloud.google.com/appengine/docs/flexible/reference/app-yaml).

## Enabling Java Virtual Machine metrics collection

You can configure App Engine flexible environment for Java to collect common metrics for Java
Virtual Machine (JVM) processes. The metrics are collected using the same
[JVM monitoring plugin](https://docs.cloud.google.com/monitoring/agent/plugins/jvm)
that [Cloud Monitoring](https://docs.cloud.google.com/monitoring) uses. To view the full list of metrics
for App Engine, see the [Google Cloud metrics guide](https://docs.cloud.google.com/monitoring/api/metrics_gcp_a_b#gcp-appengine).

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 following
[JMX](http://www.oracle.com/technetwork/articles/java/javamanagement-140525.html) system
properties in the environment variables in your `app.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]
> **Note:** The `172.17.0.1` IP enables your container to connect to the JVM monitoring plugin running in App Engine flexible environment. Port 10403 is the reserved `JMX_PORT` on the app container which the monitoring plugin connects to.