Giving an “elixir of life” to your old Java 8/11 apps with Amazon Q Code Transformation 🧪 😁 !!

Mani
7 min readFeb 21, 2024

--

Feb 2024 in Bangalore ..

Note: This is a personal blog, please refer to AWS official documentation and blogs. Also, some of the AWS services like Amazon Q are still in preview and some features will be subject to change at the time of GA. I have linked a bunch of useful references at the end of this blog.

obligatory “back story” 🤣

Java is a very popular programming language, and was quite easy to learn (at-least for me) when compared to say, C++ in 1995, when I started my IT career. My journey with Java started with the very first release 1.0 in 1995, and every year all the Java developers eagerly awaited a new release of Java at JavaOne. Every new version of Java brought new functionality, and complex concepts like Threading, Networking, I/O programming, Server side programming and others, became very easy and accessible to the masses. I started my Java journey with Honeywell India in Bangalore, and then used it extensively in the US as a consultant, and it finally became a part of my job profile during a long stint at Sun Microsystems as a Java consultant.

Java certification taken on a cold wintry morning at a Prometric center in the Midwest at Moline, Illinois in Feb 2000 !!

For newbies, there are two key terms in the Java world. JDK — Java development kit refers to the compiler and the developer tools and JVM — Java virtual machine, the runtime on which the compiled Java class runs.

I have to admit, that after Java 1.5/1.6, I lost touch with what was happening with new releases of Java over the years. While folks can keep using applications written using these older Java versions, critical things like support, security patches, operating system compatibilities, performance issues become very critical. Oracle announced the end of public updates for Java 1.8 in 2019 — https://support.oracle.com/knowledge/Middleware/2511229_1.html and there is also a nice blog on why you should upgrade from older Java versions like 8, 11 to newer Java versions like Java 17 — https://blogs.oracle.com/javamagazine/post/its-time-to-move-your-applications-to-java-17-heres-why-and-heres-how.

Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with long-term support that will include performance enhancements and security fixes. Corretto supports OpenJDK compatible 8, 11, 17 and 21 versions — https://docs.aws.amazon.com/corretto/

While writing this blog, I came across a fabulous report from the folks at New Relic on the state of the Java Ecosystem in 2023 — https://newrelic.com/resources/report/2023-state-of-the-java-ecosystem. A couple of facts from the report caught my eye:

  1. There is still a very large deployed base of Java 8 and 11 based applications:
from https://newrelic.com/resources/report/2023-state-of-the-java-ecosystem

2. Who would have thought this will happen? 😊 - Amazon is now the most popular JDK vendor — 31% of the market share in 2023 !!

https://newrelic.com/resources/report/2023-state-of-the-java-ecosystem

Anyway, the bottom line, there is still very large deployment of applications which still use older Java environments like 8 (and 11) ..

Amazon Q Code Transformation

Typically, when we are faced with older applications, we generally resort to an assessment and then go in for a application migration which is usually human centric assisted by tools. If the number of applications and complexity of these application increases, the cost of these migrations increase dramatically and may become difficult to justify to the business in terms of ROI.

What is Amazon Q?

Amazon Q is a new type of generative AI–powered assistant. It is specifically for work and can be tailored to your business to have conversations, solve problems, generate content, and take actions using the data and expertise found in your company’s information repositories, code bases, and enterprise systems.

Various avatars of Amazon Q :-) from https://aws.amazon.com/q/faqs/

At re:Invent 2023, AWS introduced a radical new service based on Generative AI called Amazon Q Code Transformation (currently in preview), which simplifies upgrading and modernizing existing application code using Amazon Q, and can perform Java application upgrades, from Java 8 and 11 to version 17, and sometime soon it will also support transformation of Windows-based .NET Framework applications to cross-platform .NET

This blog is a quick proof of concept, by using the capabilities of Amazon Q Code Transformation on a simple Java 8 based application and transform it to Java 17. There are plenty of screenshots in this blog to guide you in this transformation journey.

Note: While I have selected a fairly simple Java app, there may be more complex issues that will be encountered while performing transformation of older apps, especially which have extensive use of older third party libraries etc. .. so, your transformnation mileage may vary compared to mine.

let’s begin the transformation

I needed a Java 8 based application and I found one in this GitHub repository — https://github.com/khoubyari/spring-boot-rest-example created a few years ago. Thank you BuntyRaghani for this application. This Java web application is based on the SpringBoot 2.x framework, a very popular framework used by millions of Java developers.

Tip: A helpful command to list all the installed JVM’s in your Mac based laptop is /usr/libexec/java_home -V

list of jvm’s in my laptop

Another tip, you will need to compile the old Java app using the Java 8 or 11 compiler before using Q. You can use Amazon Corretto , where you have access to the Amazon version of the OpenJDK 8, 11 or 17 — https://docs.aws.amazon.com/corretto/

Please refer to the documentation for setting up Q. I used the Visual Studio Code as my development environment with the AWS toolkit, and downloaded Amazon Corretto 8 (for the old app) and 17 (for the transformed app). Note, that to access Amazon Q Code Transformation, the CodeWhisperer administrator needs to explicitly give access to Amazon Q features in the profile used by the organization.

VS Code with Amazon Q

Clone the sample app and compile it using Java 8 and it should compile without any errors. Load the app in VS Code, and let us start the transformation with Q, Amazon Q does its initial analysis and spits out the following messages after around 3+ minutes for this simple application ..

Code Transformation Plan

It made changes to two files ..

proposed changes
pom.xml file, left hand side is the old Java 1.8 file, and right hand side is the file changed by Amazon Q
the java code changes

Review and accept the changes. Lets do a quick test by compiling the code against Java 17 and test the deployment 🤞

compile the newly transformed app using Corretto 11

and yes, it works !!!!!

test the microservice endpoint

So, using Amazon Q Code Transformation we transformed an old Java 1.8 based application to Java 17 in just over 3 minutes !!!

One additional nice feature, which I loved, is the Chat with Amazon Q in IDEs feature. You can use this to inspect the code, and learn things like its dependencies, its functionality and others.

Q Chat inside VS Code

What we have seen is the power of Generative AI being used to transform old, legacy Java applications written using an very old Java 8 (or 11) to a newer Java version, Java 17. There are also several thousands of old .NET applications in production, and when Amazon Q Code Transformation extends support to .NET, we can ensure the longevity of these applications, some of which are extremely business critical.

Amazon Q Code Transform is also ensuring that the velocity of these code transformations changes from weeks/months to mins/hrs/days, like the following stats from an internal Amazon code transformation.

from https://aws.amazon.com/q/aws/code-transformation/

Resources

  1. Amazon Q transformation (preview)— https://aws.amazon.com/q/aws/code-transformation/
  2. Clare Ligouri’s awesome re:Invent 2023 talk and demo on Amazon Q’s transformation capabilities — https://www.youtube.com/watch?v=lBJHJmkotcI
  3. Danilo’s awesome blog — https://aws.amazon.com/blogs/aws/upgrade-your-java-applications-with-amazon-q-code-transformation-preview/
  4. The Newrelic 2023 report on java ecosystem — https://newrelic.com/resources/report/2023-state-of-the-java-ecosystem
  5. Oracle Java Magazine article on why you need to move from Java 8 to a greater version like Java 17 — https://blogs.oracle.com/javamagazine/post/its-time-to-move-your-applications-to-java-17-heres-why-and-heres-how

That’s it folks, hope this was useful. Please ping me here or on LinkedIn, if you need more information .. Namaskara 🙏

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Mani
Mani

Written by Mani

Principal Solutions Architect at AWS India, and I blog/post about interesting stuff that I am curious about and which is relevant to developers & customers.

No responses yet

Write a response