
Migrating a Legacy Java/Ant Application to Java 21 with Maven Using Amazon Q Developer
This blog post explores how to combine Amazon Q Developer CLI with Amazon Q Transformation CLI to upgrade a legacy Java 8/Ant application to Java 21 in minutes
Venugopalan Vasudevan
Amazon Employee
Published Mar 20, 2025
Many organizations maintain legacy Java applications built with older versions of Java and Ant build systems. Modernizing these applications to use current Java versions and Maven build systems offers several benefits:
- Enhanced maintainability
- Reduced security vulnerabilities
- Improved performance
- Better dependency management
- Access to modern development tools and features
Amazon Q Developer's Transformation feature excels at upgrading Maven-based Java projects from version 8 to 21, handling everything from deprecated code components and APIs to updating libraries, frameworks, and dependencies. However, it currently doesn't support direct transformation of Ant-based build systems. To bridge this gap, I will explore a two-step approach that leverages both Amazon Q Developer CLI and Amazon Q Transformation CLI. This combined solution enables a complete migration path for legacy Ant-based projects, automating the entire process - from Ant to Maven conversion and then to Java 21 - in just minutes.
For this demonstration, I'll use a sample Java/Ant project from GitHub to showcase the migration process. This example will illustrate how to:
- Convert an Ant build system to Maven using Amazon Q agentic CLI
- Upgrade the Java version from 8 to 21 using Amazon Q Transformation CLI
- Validate the migrated application
- Amazon Q Developer access
- Git installed
- Python virtual environment capability
- Amazon Q Developer CLI and Amazon Q Developer Transformation CLI installed
- Basic understanding of Java build systems
First, I prompt Amazon Q CLI chat to clone the sample repository.
> Build and verify local Ant project and fix any issues related to the build
Amazon Q will build the project using Ant based build system. It will also install Ant in case if it is not installed in the system.
Since this project is in Java 8, I prompt the CLI to use Java 8 to compile this project.
> Change Java Version to 8 and then compile this project
Amazon Q will set Java Home to 8 and compile the project . If Java 8 is not installed, it will also install Java 8.
Amazon Q has set up Java 8 and compiled the project successfully. The build process completed without any errors, and the application runs as expected.
> Migrate Ant to Maven using Amazon Q CLI and verify build.
Amazon Q will migrate the files to Maven based build system, compile and run this as well. If it encounters any compilation errors, it will also try to fix it as well.
> Commit these changes locally
Use Amazon Q CLI to commit these changes locally. This is needed for the next step.
I exit the Q CLI chat session and run the Q Transformation CLI as described in this documentation
> python -m venv qct-cli
> source qct-cli/bin/activate
> which qct
> qct configure
and follow the prompts> qct transform --source_folder /home/ec2-user/qct/ant-sample --target_version 21
Amazon Q Transformation agent will perform the upgrade process and create a new local branch with the changes.
> cd ant-sample
> git branch
> git diff mainline <
Review the changes with
git diff
between main branch and QCT CLI created branch.> Set Java Home to 21 and compile this Maven project
Amazon Q has successfully set JAVA_HOME to Java 21 and compiled the Maven project
The combination of Amazon Q Developer CLI and Amazon Q Transformation CLI demonstrates a powerful solution for modernizing legacy Java applications, transforming what traditionally takes weeks of manual effort into an automated process that completes in minutes. This integrated approach successfully tackles both the Ant to Maven conversion and Java 8 to 21 upgrade while minimizing risk and ensuring code quality. Beyond the immediate technical benefits of improved dependency management and access to modern Java features, organizations gain significant business value through reduced maintenance costs, enhanced security, and improved application performance. This solution exemplifies how Amazon Q Developer's AI-powered capabilities can simplify complex migration challenges, providing a reliable path to modernization that positions applications for future growth and innovation.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.