Passer au contenu principal
← Blog

AI tools for Java migration: pick by the job, not the brand

· 10 minutes de lecture
webforJ
Do it all in Java! Build in Java, deploy to the Web.

cover image

You have a Java app that has been in production for years, a deadline that keeps moving, and a long list of AI tools that all claim they can help. Comparing them by brand does not get you far, because a migration is not one task. It is five or six different jobs, and each one needs a different kind of help.

The best AI tools for Java migration are coding assistants such as Claude Code, GitHub Copilot, Cursor, Gemini CLI and Codex, matched to the job at hand and grounded in the real documentation of the framework you are moving to. That last part decides most of the outcome. With webforJ, the full-stack Java framework, one AI plugin gives those assistants the real docs, project scaffolding and ready-made workflows, so the code they write for your new screens targets APIs that exist.

Why the target beats the tool​

Coding assistants work from models trained on a snapshot of public code. When you ask it to read your old code, it has all the evidence it needs, because the code is in front of it. When you ask it to write code for a framework, it has only its memory, and memory is where invented methods, wrong constructors, and renamed annotations come from.

That is why we think about AI for legacy Java in two halves. Reading the old system is a job the tool can do well with nothing but your repository. Writing the new system is a job whose quality depends on what the tool can look up while it works. A target framework that gives the assistant a source of truth turns a guessing game into a checked one.

None of this removes the reviewer. A person reads every change, runs the tests, and decides what ships.

Job 1: understanding the legacy code​

Before anything moves, someone has to know what the old app does. This is the job where AI helps most with the least setup.

A coding assistant that can read a repository and run commands can list the screens, trace which classes a screen calls and show which database tables a feature reads. Ask for a screen inventory with the data each screen needs and the business rules it applies. That inventory becomes your migration backlog.

What grounds it here is your own code and your database schema. There is no framework gap to worry about yet. The weak spot is confidence. A summary can be fluent and still wrong, so spot-check it against the code for the screens that matter most, and keep the inventory in the repository where the team can correct it.

Job 2: upgrading versions​

Version upgrades are mostly mechanical, and mechanical work is better done by a recipe than by a model improvising. OpenRewrite is an automated refactoring project for Java. Its recipes rename types, change dependencies and rewrite deprecated calls the same way every time, and a dry run shows you the diff before anything changes.

The assistant's role is to drive the recipe and handle what is left. For projects already on webforJ, we publish upgrade recipes between webforJ versions. You add the OpenRewrite Maven plugin with the webforj-rewrite dependency, then run mvn rewrite:dryRun to preview the patch and mvn rewrite:run to apply it:

<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.36.0</version>
<configuration>
<activeRecipes>
<recipe>RECIPE_NAME</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>com.webforj</groupId>
<artifactId>webforj-rewrite</artifactId>
<version>TARGET_VERSION</version>
</dependency>
</dependencies>
</plugin>

Where a one-to-one replacement does not exist, the recipe leaves a TODO comment with instructions, and those are the lines a person or an assistant resolves. Recipe names for each webforJ version are listed in automated upgrades, and the webforj-upgrading-versions Agent Skill in the AI plugin walks an assistant through the same flow, including resolving the TODO comments.

What grounds this job is the recipe, not the model. Use the assistant to run it, read the diff, and fix the leftovers. Do not ask it to rewrite deprecated calls from memory when a recipe exists.

Job 3: porting screens to a web UI​

This is the job people mean when they ask about AI Java code migration, and it is the one with the biggest gap between a good and a bad result. The source is a Swing frame, a JSP page, a JSF view, or a Struts action. The target is a screen in a web UI built in Java.

An assistant can read the old screen, identify its fields, tables, buttons and event handlers, and write the equivalent in the new framework. Whether that code is right depends on whether the assistant knows the target. We cover the screen-by-screen method for desktop apps in Swing to web migration and the decision between rebuilding and embedding in how to migrate a Java desktop app with AI. The short version is to keep the domain layer and move one screen at a time. For Swing, Webswing integration runs the existing app in the browser so users are not waiting for the last screen to be ported.

What grounds this job is the target framework's documentation, and that is where webforJ is built to help, which the next section covers.

Job 4: writing tests for the ported code​

A port without tests is a port you cannot trust. Assistants are good at drafting test cases from a described behavior, such as "the Save button stays disabled until the name field has a value".

The practical limit is how tests run. Browser-based tests can be slow and flaky, which is hard on an agent that wants to run them after every change. webforJ's TestBed, available since 26.03, runs a view inside a plain JUnit test with no browser and no server. A test adds the view, acts on it the way a user does and checks the result from Java, and every interaction finishes before the next line runs. That makes it practical to ask an assistant to write a test, run mvn test and read the result in one loop. Java UI testing without a browser shows the structure of a test.

What grounds this job is the test run itself. A generated test that has never failed proves little, so make the assistant show you a red run before the green one.

Job 5: keeping the result maintainable​

The last job is the one that gets skipped. A migration that ends in thousands of lines of unfamiliar generated code has traded one legacy system for another. AI helps with renaming for consistency, extracting repeated layout into reusable components and checking new code against conventions you write down once. Put the conventions in the repository, point the assistant at them, and review its output against them.

A target where a view is one Java class with the layout, events and state together gives a reviewer one place to read.

Which AI tool for which migration job​

JobKind of toolWhat grounds itWhat a person checks
Understand legacy codeCoding assistant with repository accessYour code and schemaSummaries against the source
Upgrade versionsRefactoring recipe, driven by an assistantOpenRewrite and webforj-rewrite recipesThe dry-run diff and TODO comments
Port screens to the webCoding assistant with docs accesswebforJ AI plugin: MCP server and Agent SkillsBehavior of each ported screen
Write testsCoding assistant that can run MavenTestBed runs without a browserThat tests fail when they should
Keep it maintainableCoding assistant with written conventionsYour conventions and the framework docsNaming, structure and reuse

Claude Code, GitHub Copilot, Cursor, Gemini CLI and Codex differ in where they run and how you drive them. For the preceding migration jobs, the difference between them is smaller than the difference between an assistant with grounding and one without.

How webforJ grounds your AI tools​

The webforJ AI plugin installs into Claude Code, GitHub Copilot, Cursor, Gemini CLI and Codex, so you keep the tool your team already uses. It bundles two things.

The MCP server lets the assistant look things up in the webforJ knowledge base instead of recalling them. It can also scaffold a Maven project from the official archetypes. When the assistant ports a JTable to a webforJ Table, it can ask what the Table API actually offers.

The Agent Skills tell the assistant when to use those tools and in what order. There are skills for building forms with data binding and validation, securing routes, localizing apps, handling timers and background work, styling, wrapping components, and upgrading versions.

Then there is the compiler. A webforJ view is Java, so a wrong method name fails the build and the error tells the assistant what to fix. Add TestBed and the assistant can prove behavior without a browser. The pieces fit into a loop: look up the API, write the code, compile it, run the test, and hand a person a diff that has already passed the compiler and the tests.

We are careful about what that loop promises. It raises the odds that the code you review is correct. It does not replace the review, and even with the plugin installed an assistant can still produce wrong code in complex cases. Read the diff, run the tests and keep the change small enough to understand.

Run the upgrade recipe on a branch​

If you are not sure where to begin, begin with Job 1 and Job 2, because they are contained and teach your team how the assistant behaves on your code. Ask it for a screen inventory of your app. Then, once you are on webforJ, pick one project, add the OpenRewrite plugin on a branch, run mvn rewrite:dryRun and read the patch. When you are ready to port a screen, generate a project with startforJ, install the plugin and follow the getting started guide for the first view.

Frequently asked questions​

What are the best AI tools for Java migration?​

Coding assistants such as Claude Code, GitHub Copilot, Cursor, Gemini CLI and Codex handle the reading, writing and testing jobs, and OpenRewrite recipes handle mechanical version upgrades. Choose by job, and connect the assistant to your target framework's documentation so it does not guess.

Can AI migrate legacy Java code by itself?​

AI can help with the reading, porting and test writing, but a person should review every change. Work screen by screen, keep the business logic, and run tests after each step so mistakes show up early.

What is the best AI tool for Java programming?​

The tool matters less than what it can reach while it works. A coding assistant connected to your framework's real docs through MCP and loaded with matching Agent Skills writes more accurate Java than the same assistant working from memory. The webforJ AI plugin sets that up in one install.

How does the target framework change AI results?​

An assistant writing for a framework it has seen little of tends to invent methods and use outdated annotations. A framework that offers a docs lookup, workflows and a compiler-checked single-language codebase gives the assistant something to verify against, which helps the code you review compile and behave as intended.

Vous développez quelque chose avec webforJ ?

Échangez avec l’équipe au sujet de votre projet, d’une migration ou de la pertinence de webforJ.

Contactez-nous