Goal
In this tutorial, we’ll cover the how and why of upgrading a Java 8 project to Java 11 on Platform.sh.
Preparation
This tutorial assumes you have
- A working Java 8 application already deployed on Platform.sh.
- A text editor of your choice.
Problems
Java 8, the old Java LTS release, is no longer maintained. As an unmaintained version it will no longer receive security fixes, and so over time there will be more and more known-but-unfixed security issues found with it.
Java 11 is the new LTS release, and is both more secure and more performant. Leonardo Zanivan’s blog covers the major new features, including:
- Next LTS version
- Full support for containers
- Support parallel full garbage collection on G1.
- Free Application Class-Data Sharing feature.
- Heap allocation on alternative memory devices.
- New default set of root authority certificates.
- New ZGC and Epsilon garbage collectors.
- Ahead-of-time compilation and GraalVM.
- Transport Layer Security (TLS) 1.3.
- Compact Strings
- Make G1 the Default Garbage Collector
Several benchmarks on the JVM improvements show an improvement of around 20%. Furthermore, code written for Java 8 doesn’t need to be updated to run on the Java 11 JVM, but still sees improvements in both memory usage and boot up time.
To keep your code working you need to be aware of JEP 320: Remove the Java EE and CORBA Modules. If you are using those modules you’ll need to re-add them in your dependency management tool. See this blog post for general migration tips.
Steps
To update the application, you need to update a single file: the .platform.app.yaml
file. On a development branch (not production), find the type
property:
name: app
type: "java:8"
Update this line to Java 11:
name: app
type: "java:11"
Commit the changes and push.
Platform.sh will then build a new container using Java 11 instead of Java 8. The new version will be used for both the build process (compilation) and the running environment.
Once you’re satisfied that the update is safe to complete, merge this new branch to master
and push.