Upgrading the Java version for your application
To upgrade your Java™ code, you first build and analyze your application, and then fix any issues that are identified. Depending on the issues, the ability to fix them can be automated or self-directed.
Beginning with version 1.1, you can build your application without Maven, but with limitations. For more information, see Applications built with non-Maven build tools.
Before you begin
- Set up your enterprise Java environment.
- Install the Visual Studio Code extension, the Eclipse IDE plug-in,
or the IntelliJ
IDE plug-in.
When you install the Visual Studio Code extension, the Eclipse IDE plug-in, or the IntelliJ IDE plug-in, you must apply a license key. If the license key is not applied, an error is displayed on the upgrade page and the Build and analyze button is disabled.
If you encounter a problem using Application Modernization Accelerator Developer Tools, refer to the Troubleshooting page.
Time required to analyze your code
The amount of time to analyze your application varies. The following times are typical.
Table 1. Time required to analyze
| Time | Application details |
|---|---|
| Seconds to a few minutes | Fewer than 100 classes |
| 2 to 10 minutes | 20,000 to 50,000 lines of code |
| 10 or more minutes | 300,000 lines of code |
Analyzing your application to upgrade the Java version
The analysis provides you with a list of issues to address. After you fix the issues, the Java version for your application is upgraded.
If you revert the changes to your code, you must click Return to analyze and do a full analysis if you want to do the Java upgrade again.
- In your IDE, right-click any item in the hierarchy in the directory of the application that you want to upgrade, click Modernize Java applications, then click Upgrade Java Version.
-
On your Upgrade <your application name> page, select the analysis parameters, which define the rules that the application is analyzed against.
-
Change the Java source, which is displayed automatically with a recommended value.
The Java source version is the Java version that you are upgrading from. Based on the Java version detected in the build configuration, IBM Application Modernization Accelerator Developer Tools recommends a Java version to use as the source. You can choose a different Java version from the list of supported Java versions if that is appropriate for your application. The build configuration is in the Maven pom.xml file.
The Java version that is recommended is the one that is detected in the build configuration. Or, it is the best available Java version given the Java version that was detected. For example, if Java 9, which is not supported, is specified in the build configuration, Java 8 is the recommended Java version. Java 8 is recommended since it is the closest supported Java version for the analysis, and since it is earlier than the detected Java version.
Important: The minimum-supported Java version is Java 6. -
Select the Java target.
The Java target version is the Java version that you are upgrading your Java application to. The target versions that you can select from are long-term (LTS) Java releases.
-
Build the application and then analyze it.
Application analysis is done on the application binary. The application must be built before analysis begins.
- For Maven builds, you can either manually or automatically build the application.
Click either Analyze after you manually build the application or Build and analyze to automatically build and analyze the application.
After your application is built and analyzed, the issues to fix or review are displayed. Depending on the issues to fix, the ability to fix them can be automated or self-directed. The issues to review don't require a code change to migrate your code. However, they might need to be verified or tested.
When you click Build and analyze, the application is built at its current Java source version, so it can be analyzed for Java upgrade issues. Make sure to configure the IDE with the Java developer kit of the Java source version, so the IDE can successfully build the application.
Tip: When you build and analyze, if you have issues with a multimodule project that includes a submodule withliberty-assemblypackaging, run mvn install at the root level of the project and try again. - For non-Maven builds, manually build the application and then click
Analyze.
After your application is built and analyzed, the issues to fix or review are displayed. The issues to fix are self-directed. The issues to review don't require a code change to migrate your code. However, they might need to be verified or tested.
- For Maven builds, you can either manually or automatically build the application.
-
Fixing issues and reviewing additional information for your application
The Upgrade <your application name> page lists the following information:
- The Java version source and the Java version target
- Links to a technology report, an inventory report, and an analysis report
- Tabs for issues to fix, which can be automated or self-directed fixes, and for additional information
The target Java developer kit is required when you run automated fixes and when you build the application after the Java version target changes are made. Make sure that the target Java developer kit is configured for your IDE.
- The plug-ins for the Eclipse IDE and the IntelliJ IDE automatically try to find the correct Java developer kit that matches the Java version target. The Java version target is from the set of all configured Java developer kits in the IDEs.
- In the Visual Studio Code IDE, you must manually change the Java developer kit configuration.
- Completing automated fixes for Maven builds
-
If you have an Automated fixes tab with one or more fixes, select the tab.
Because IBM Application Modernization Accelerator Developer Tools completes the fixes for you, you do not need to make any code changes.
- Expand the instructions and read them.
- Optionally open the issue to review the description of the issue.
- Click Run automated fixes.
- The Automated fixes are fixed.
- External issues remain in the list until you update the associated dependency.
- When Run automated fixes completes, click Rebuild and refresh to update the list of issues.
Important:- If the automated fixes fail to run and produce compilation errors in the console output, make
sure to update the version of the
maven-compilerplug-in to 3.13.0 or newer. - When you run automations, if you have issues with a multimodule project that includes a
submodule with
liberty-assemblypackaging, run mvn install at the root level of the project and try again.
- Completing self-directed fixes
-
If you have a Self-directed fixes tab with one or more fixes, select the tab.
You change the code and determine how to fix the code.
- Expand the Instructions and follow the instructions.
- Expand each issue.
- Click Read more to expand the issue.
- Click the file that is listed in the issue. The file opens in the editor.
- As you fix issues, click Rebuild and refresh until all self-directed fixes are fixed.
Tip: For certain self-directed fixes, you might be able to use the generative AI capabilities in watsonx Code Assistant™ for Enterprise Java Applications. - Addressing additional information
-
If you have an Additional information tab with a number of one or more on it, select the tab.
The issues that are listed on the tab are determined in the same way that issues on other tabs are determined. Although the additional information issues do not require a change to your code, review the issues so you can ensure that your application is working when your code is migrated.
The additional information might indicate issues, such as minor behavioral changes in an API and what to do about them.
-
Expand the instructions and follow them.
-
Click each issue.
- Click Read more to expand the issue.
- Click the link on the file that is listed in the issue to review the code.
-
- Working on external issues outside the current application
-
While you work on fixes, some might be categorized as external issue occurrences outside the current application. The source code for these issues is in specified archives that are not part of the current source application.
If the archive is a library that your organization owns.
-
You can open its associated source code as a separate application and use IBM Application Modernization Accelerator Developer Tools to remediate the issues there.
-
Then, you can update your current application to use the new remediated version.
If the archive is a library that your organization doesn’t own.
-
You need to update to a version that does not contain this issue. If no such version exists, you might need to use a different technology.
-