Setting up your enterprise Java environment

If you want to work with enterprise Java™ applications, you need to set up your environment for your IDE.

Setting up Visual Studio Code

Java requirements

The requirements to use IBM® Application Modernization Accelerator Developer Tools in Visual Studio Code are:

Table 1. System requirements
Item Details
Java Java SE 11 with Java Developer Kit 11, or a later version
Maven Use Maven to build your application. If you are using Liberty Tools and the Liberty Maven plug-in to build your app or project, use at least Maven 3.8.6.

Beginning with version 1.1, you can use Application Modernization Accelerator Developer Tools with applications that are built with non-Maven tools, but with limitations. For more information, see Applications built with non-Maven build tools.

If you use Maven to build your applications, you can use automated fixes for your application modernization and Java upgrade. For builds that don't use Maven, the issues to fix are self-directed.

Set environment variables

Set up your environment variables.

  • JAVA_HOME

    For Maven built applications only, set the JAVA_HOME environment variable the same way that you do for Maven. Set it to the JDK directory that contains the /bin directory so that your Java executable file is in the $JAVA_HOME/bin/java path.

    You can set the JAVA_HOME environment variable to build your application at a different version, for example, Java 11.

  • PATH

    Set the PATH environment variable to include the mvn executable file.

    • Windows: mvn.cmd
    • macOS: mvn
    Note: If you use the Visual Studio Code terminal to set the environment variables, you need to restart Visual Studio Code to apply the changes.
Determining the Java developer kit

For Visual Studio Code, if you are using the Extension Pack for Java, IBM Application Modernization Accelerator Developer Tools determines the Java developer kit to use in this order of precedence:

Table 2. Java developer kit order
Order of precedence Description
1 Globally-configured Java developer kit for automatic building in the Red Hat extension, which is java.configuration.runtimes in the
IDE
      settings.json
file
2 java.jdt.ls.java.home or java.home IDE settings if they are present
3 JAVA_HOME system environment variable, or else JDK_HOME
4 The Java developer kit in the system PATH

When application modernization and upgrade features are used, you can verify which Java developer kit is being used:

  1. In Visual Studio Code, click View, then click Output.
  2. In the Output view, use the dropdown menu to select IBM AMA Dev Tools.
  3. Check for a message such as Using the Java developer kit that is defined in <location> to run IBM Application Modernization Accelerator Developer Tools components. The path is: <path>.
Set logging level

To adjust logging for the Visual Studio Code extension:

  1. In Visual Studio Code, open the extension settings for IBM AMA Dev Tools.
  2. In IBM AMA Dev Tools: Log level, switch from the default of INFO to another setting such as WARN.

Setting up the Eclipse IDE

  • Determining the Java installation
  • Maven setup

    Beginning with version 1.1, you can use Application Modernization Accelerator Developer Tools with applications that are built with non-Maven tools, but with limitations. For more information, see Applications built with non-Maven build tools.

    If you use Maven to build your applications, you can use automated fixes for your application modernization and Java upgrade. For builds that don't use Maven, the issues to fix are self-directed.

Determining the Java installation

For Eclipse, the Java installation is determined in this order:

  • The installation that is configured in the project's build path
  • The default Java installation for the Eclipse IDE

To modernize and upgrade Maven built applications, the automated fixes use the Java developer kit installation that best matches the target Java version that you chose.

You need to:

  1. Install the Java developer kit.
  2. In the Eclipse IDE settings, open the Java section and add the installation to the Installed JREs.
Maven setup

Use Maven to build your application.

Setting Maven on the path is optional. The Maven executable installation is determined in this order:

  • Check for a Maven Wrapper in the project
  • Check if mvn is available on the PATH
  • Generate a Maven Wrapper in the project root by using the default Maven version for the Eclipse IDE
Note: For macOS operating systems, the environment variables might not be set as expected when you run Eclipse. To fix the problem, you can restart Eclipse through the Finder tool by right-clicking your Eclipse application and choosing Show Package Contents. Enter the newly displayed Contents folder, select MacOS, and then run Eclipse by clicking the executable code.

Setting up IntelliJ IDEA

Determining the Java installation

IntelliJ IDEA comes bundled with the JetBrains Java runtime environment. For application modernization and upgrade, the automated fixes use the Java developer kit installation that best matches the target Java version that you chose.

Automated fixes are for Maven built applications only.

You need to:

  1. Install the Java developer kit.
  2. Add the SDK to the Installed JDKs by using one of the following methods.
    • In your IntelliJ IDE project settings (File > Project Structure), open Platform Settings > SDKs and use Add new SDK (the + icon).
    • In your IntelliJ IDE Project Settings > Project page, open the drop-down menu under the SDKs setting and click Add JDK from disk.
  3. On the Project Settings > Project page, under the SDKs setting, select the installed Java developer kit.
Maven setup

Use Maven to build your application.

Setting Maven on the path is optional. The Maven executable installation is determined in this order:

  1. Check for a Maven Wrapper in the project.
  2. Check if a Maven installation has been specified with the MAVEN_HOME environment variable.
  3. Check if mvn is available on the PATH.
  4. Use the built-in Maven installation from IntelliJ IDEA.