Migrating from Java 8 to Java 12

Author: Shazin Sadakath


We have talked about Java 12 features in a previous post and today we are going to have a look at how to Migrate from Java 8 to Java 12.

According to "JVM Ecosystem Report 2018" the most widely (79 %) used JVM version as of now is Java 8. Eventhough Java 9 was released in 2017 and to this date 3 more versions of Java has been released making the latest version of Java 12, many enterprises and business are still reluctant to migrate. This is understandable because with introduction of the Java 9 encapsulation of internal APIs and removal of tools.jar and rt.jar, Developers, Management feared that migration would affectively break what they already have.

This post is intended to address that concern enable Migrating to the latest version of Java 12 from Java 8. Migrating to latest version will result in added features, increased performance and operational cost reduction. Following steps can be used as guidelines when doing the migration:

  1. Migration of an application requires an understanding of existing application functionalities and features it makes use of from the Java 8 to ease the process. List these down and check whether there are any internal APIs or tools.jar, rt.jar classes being used.
  2. Take of Compiler Warnings as Java 10 and Java 11 have removed quite a number of APIs. Follow the workarounds suggested by the compiler warnings.
  3. Check for the usage of Internal APIs (sun.misc.*) using the Java 12 CLI tool "jdeps -jdkinternals"
  4. Upgrade build tools. Gradle needs to be updated to version 5 or later and Maven needs to be updated to 3.5.0 or later.
  5. Upgrade dependencies. Most of the common libraries are already updated to Java 9 so make use of those in your application.
  6. Add dependencies for moved functionality. Functionalities such as JavaFX, JAXB, JavaEE etc are removed from JVM since Java 9. These needs to manually included in your build tool (Maven, Gradle).
  7. Run the application as is in Java 12. Java is supposed to be backward compatible so it will support your application for some extent. This can be done in CI tools to start off.
  8. Compile with Java 12.
  9. Use the features offered from Java 9 onwards.

 

References

 



Tags: Java12 Migration Upgrading Java8
Views: 192
Register for more exciting articles

Comments

Please login or register to post a comment.


There are currently no comments.