Move your app into the flexible environment
Google supplies a Java runtime for the flexible environment that works with applications that were originally written for the App Engine standard environment and use the standard environment's APIs. Because this runtime is backwards-compatible it is called a "compat" runtime.
If you would like to deploy your application on the flexible environment and
continue to use the standard environment APIs, select the compat runtime by
adding the setting
<vm>true</vm> to the application's
<?xml version="1.0" encoding="utf-8"?> <appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <threadsafe>true</threadsafe> <vm>true</vm> </appengine-web-app>
Most users will also wish to add the appengine-maven-plugin: to the
section of their
<plugins> <plugin> <groupId>com.google.cloud.tools</groupId> <artifactId>appengine-maven-plugin</artifactId> <version>0.1.2</version> </plugin> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.3.7.v20160115</version> </plugin> </plugins>
With this configuration, your application uses an OpenJDK / Jetty 9.3 Java runtime that is compatible with a subset of the App Engine APIs:
As you become more familiar with the flexible environment you should use the native features of the Java runtime and the Google Cloud client libraries for Java rather than App Engine SDKs.
Deploying your app
- Continue to use the same WAR directory that contains
If you want to set environment variables, you can add them to the
appengine- web.xmlfile. For example, to set the temporary directory:
<env-variables> <env-var name="TMPDIR" value="/path/to/directory/" /> </env-variables>
Test the app by running
- Deploy the application using
Running in the flexible environment
You must also take into account these differences when migrating an existing app:
- The flexible environment supports manual and automatic scaling. If your app uses basic scaling, you'll need to change that in your configuration file.
- Apps running in the flexible environment are not assigned instance classes.
Instead, you specify resources in the
- Sandbox restrictions are lifted and it is possible to include native code in your classes.
Moving to Java 8
To use Java 8, add a Dockerfile to your
webapp/ directory with the following:
FROM gcr.io/google_appengine/jetty9-compat ADD . /app/
Additional information can be found at The Java 8 Runtime.