Access legacy bundled services for Java 11+ Stay organized with collections Save and categorize content based on your preferences.
This page describes how to install and use the bundledservices with the latest supportedJava version forthe App Engine standard environment. Your app can access the bundled services through theApp Engine API JAR.
Before you begin
Refer to thelist of legacy bundled services APIsyou can call in the latest supported Java version.
This page requires that your app is running asupported Java version. To migrateyour app from the first-generation to the second-generation runtime, seeMigrate from Java 8 to the latest Java runtime and themigration considerations section.
If you use legacy bundled services and want to upgrade to Java 25 (preview),seeUpgrade an existing applicationto learn more about your configuration options.
Install the App Engine API JAR
To use legacy bundled services in your latest supported Java app, you mustuse anappengine-web.xmlfile to configure your app (instead of anapp.yaml file).
The following example demonstrates how to add configuration settings in yourappengine-web.xml for different Java versions. To use the latest supported version onthe default configuration, you must update your application servlets anddependencies to include theJakarta namespace. To learn more about your configuration options,seeUpgrade an existing application.
Add the following settings in yourappengine-web.xml file depending on the Java version:
Java 25 (preview, EE 11)
<?xmlversion="1.0"encoding="utf-8"?><appengine-web-appxmlns="http://appengine.google.com/ns/1.0"><runtime>java25</runtime><system-properties><propertyname="appengine.use.EE11"value="true"/></system-properties><app-engine-apis>true</app-engine-apis></appengine-web-app>Java 21 (EE 10)
<?xmlversion="1.0"encoding="utf-8"?><appengine-web-appxmlns="http://appengine.google.com/ns/1.0"><runtime>java21</runtime><system-properties><propertyname="appengine.use.EE10"value="true"/></system-properties><app-engine-apis>true</app-engine-apis></appengine-web-app>Java 17 (EE 8)
<?xmlversion="1.0"encoding="utf-8"?><appengine-web-appxmlns="http://appengine.google.com/ns/1.0"><runtime>java17</runtime><system-properties><propertyname="appengine.use.EE8"value="true"/></system-properties><app-engine-apis>true</app-engine-apis></appengine-web-app>To specify the legacy bundled services as a dependency, add the followinglines in yourpom.xml file:
<dependency><groupId>com.google.appengine</groupId><artifactId>appengine-api-1.0-sdk</artifactId><version>2.0.31</version><!--orlater--></dependency>If your app uses aweb.xml file, you must add the<app-engine-apis> elementand set it totrue:
<app-engine-apis>true</app-engine-apis>To deploy your Java 25 (preview) app, run themvn appengine:deploycommand, or thegcloud app deploy ~/my_app/WEB-INF/appengine-web.xmlcommand on a compiled and staged web application.
Default entrypoint for Java 25 (preview)
Java 25 (preview) applications benefit from extra userconfiguration when starting the JVM for web applications.
The default entrypoint used to boot the JVM is generated by App Engine buildpacks.Essentially, it is equivalent to define this entrypoint in theappengine-web.xml file. For example:
java --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED -showversion -Xms32M -Xmx204M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:+PrintCommandLineFlags -Dclasspath.runtimebase=/base/java_runtime -Djava.class.path=/base/java_runtime/runtime-main.jar -Djava.library.path=/base/java_runtime: com/google/apphosting/runtime/JavaRuntimeMainWithDefaults --fixed_application_path=/workspace /base/java_runtime
We don't recommend changing this default entrypoint as the memory settings are calculated based on the instance type (F1, F2, F4) and memory available.
By default, we use--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED to open some necessary JDK APIs.
Entry Point Features
The entry point for thesecond-generationJava versions can be customized with user-defined environmentvariables added in theappengine-web.xml configuration file.
The following table indicates the environment variables that can be used to enable/disable/configure features, and the default values if they are not set:
| Env Var | Description | Type | Default |
|---|---|---|---|
CPROF_ENABLE | Stackdriver Profiler | boolean | false |
GAE_MEMORY_MB | Available memory | size | Set by App Engine or/proc/meminfo-400M |
HEAP_SIZE_RATIO | Memory for the heap | percent | 80 |
HEAP_SIZE_MB | Available heap | size | ${HEAP_SIZE_RATIO}% of${GAE_MEMORY_MB} |
JAVA_HEAP_OPTS | JVM heap args | JVM args | -Xms${HEAP_SIZE_MB}M -Xmx${HEAP_SIZE_MB}M |
JAVA_GC_OPTS | JVM GC args | JVM args | -XX:+UseG1GC plus configuration |
JAVA_USER_OPTS | JVM other args | JVM args | |
JAVA_OPTS | JVM args | JVM args | See below |
If not explicitly set,JAVA_OPTS is defaulted to:
JAVA_OPTS:=-showversion \ $JAVA_HEAP_OPTS \ $JAVA_GC_OPTS \ $JAVA_USER_OPTSWhenCPROF_ENABLE is true, the default entrypoint adds thePROFILER_AGENT as:
-agentpath:/opt/cprof/profiler_java_agent.so=--logtostderr
For example, if your application code needs more-add-opens flags, you can use theJAVA_USER_OPTS environment variable defined in theappengine-web.xml file:
<env-variables><env-varname="JAVA_USER_OPTS"value="--add-opensjava.base/java.util=ALL-UNNAMED"/></env-variables>Migration considerations
You should be aware of the following considerations if you are migrating toa second-generation Java runtime and your app uses legacy bundled services:
- To test the legacy bundled services capabilities in your second-generationJava app, you can use thelocal development server.
- Unlike the Java 8 runtime, the second-generation Java runtimesinclude JVM as part of the instance memory. If you see memory-related errors in the logs, considerincreasing the instance class size in your
appengine-web.xmlfile. - If your application is trying to call an API which is notenabled for the second-generation Java runtimes, it will receive a
com.google.apphosting.api.ApiProxy$FeatureNotEnabledExceptionerror. - All applications are assumed to be thread safe in the second-generation Javaruntimes. You must remove the
threadsafeelement in yourapp.yamlorappengine-web.xmlfile whenMigrate from Java 8 to the latest Java runtime.
Example (Datastore)
For an example of how to use Firestore in Datastore mode (Datastore), see thelegacy bundled services for Java 11code sample in GitHub.
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.