| copyright |
|
||
|---|---|---|---|
| lastupdated | 2025-08-22 | ||
| keywords | |||
| subcollection | watsonx-code-assistant |
{{site.data.keyword.attribute-definition-list}}
{: #cloud-setup-wca-java-env}
[{{site.data.keyword.wca_short}}]{: tag-blue} [Standard plan]{: tag-purple}
If you're using the Standard plan and want to work with enterprise Java applications, you need to set up your environment for your IDE. {: shortdesc}
{: #cloud-setup-wca-java-env-requirements}
The requirements to use {{site.data.keyword.wcaej_short}} in Visual Studio Code or in Eclipse are:
| 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 Maven 3.8.6 or a later version. |
| {: caption="System requirements" caption-side="bottom"} |
{: #cloud-setup-wca-java-env-vscode}
{: #cloud-setup-wca-java-env-variables}
Set up your environment variables.
{: #cloud-setup-wca-java-env-java-home}
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 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.
{: #cloud-setup-wca-java-env-path}
Set the PATH environment variable to include the mvn executable file.
- Windows:
mvn.cmd - macOS:
mvn
If you use the Visual Studio Code terminal to set the environment variables, you need to restart Visual Studio Code to apply the changes. {: note}
{: #cloud-setup-wca-java-env-extension-pack}
For Visual Studio Code, if you are using the Extension Pack for Java, {{site.data.keyword.wca_short}} determines the Java developer kit to use in this order of precedence:
| 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 | JDK_HOME system environment variable. |
| 4 | JAVA_HOME system environment variable. Required if items 1 through 3 aren't set. |
| {: caption="Java developer kit order" caption-side="bottom"} |
When {{site.data.keyword.wcaej_short}} features are used, such as Java modernization or upgrade, you can verify which Java developer kit is being used:
-
In Visual Studio Code, click View, then click Output.
-
In the Output view, use the drop-down list to select WCA.
-
Check for a message such as
Using the Java developer kit that is defined in <location> to run watsonx Code Assistant components. The path is: <path>.
{: #cloud-setup-wca-java-env-log-level-vscode}
To adjust logging for the Visual Studio Code extension:
-
In Visual Studio Code, open the extension settings for {{site.data.keyword.wca_short}}.
-
In Wca: Log level, switch from the default of
INFOto another setting such asWARN.
{: #cloud-setup-wca-java-env-eclipse}
{: #cloud-setup-wca-java-env-eclipse-java-install}
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 IDE
For application modernization and upgrade, the automated fixes use the Java developer kit installation that best matches the target Java version that you chose. You need to:
- Install the Java developer kit.
- In the Eclipse IDE settings, open the Java section and add the installation to the Installed JREs.
{: #cloud-setup-wca-java-env-eclipse-maven}
Make sure to use Maven to build your application.
Maven is required to be set on the PATH.
Set the PATH environment variable to include the mvn executable file.
| Operating system | Executable file |
|---|---|
| Windows | mvn.cmd |
| macOS | mvn |
| {: caption="Maven executable files" caption-side="bottom"} |
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 by using the Finder tool to right-click your Eclipse application and choose Show Package Contents. Open the Contents folder, select MacOS, and then run Eclipse by clicking the executable code.
{: note}
{: #cloud-setup-wca-java-env-mmr-aggregate}
{{site.data.keyword.wca_short_cap}} uses the aggregator pom.xml file to build and manage the entire multimodule Maven project. When {{site.data.keyword.wca_short}} attempts to do builds and other Maven-related activity, it uses the multi-module root (MMR) to locate the aggregator pom.xml file.
- The MMR first searches the highest level project directory for the aggregator
pom.xmlfile. - If the MMR doesn't find the file, it searches the project directory by going from the highest to the next highest directory structure, and so on, until it finds an aggregator
pom.xmlfile. - If the MMR again does not find an aggregator
pom.xmlfile, it searches the project directory by going from the highest to the next highest directory structure, and so on, until it finds a regularpom.xmlfile. A regularpom.xmlfile indicates that the Maven project is a single module project instead of a multi-module project.
However, there is an extra restriction. The multimodule project must have one WAR file or one EAR file. There can be multiple WAR files if there is a single EAR file. But, if there are multiple WAR files and no EAR file, then the project is not supported. The reason is so that {{site.data.keyword.wca_short}} can analyze the correct binary and place the Liberty configuration file (server.xml) in the correct submodule.