Java Virtual Machine requirements

Klocwork recommends you use a Java Runtime Environment (JRE) and a Java Development Kit (JDK), such as OpenJDK, that is compatible with the platform you are using.

Install a supported 64-bit Java 17 or later version before installing or running Klocwork tools that require Java (for example, the Server tools, Build tools, and Command-line and Validate packages).
The Klocwork Desktop Java plugins for Eclipse and IntelliJ IDEA require a Java 8 or later compatible JRE. Ensure that your IDE is running the appropriate version of Java.
kwant requires a JDK compatible with Java 17 or later. Ensure that your environment is configured to use the correct JDK.
Environment variable What it controls Version required
KW_JAVA The Java Klocwork runs on Java 17 or later
JAVA_HOME The Java your build runs on The version that your project requires
JRE_HOME The Java the Validate server runs on Java 17 or later

For example:

JAVA_HOME=C:\Java\jdk1.8.0_202
KW_JAVA=C:\Java\jdk-17.0.10\bin\java.exe
Set KW_JAVA to the executable (for example, \bin\java.exe), not the folder (for example, jdk-17.0.4).
Set KW_JAVA to point to a specific java or java.exe executable when you want Klocwork to use a customer-managed Java installation.

Java resolution order

Klocwork tools that require Java look for a JRE in a platform-specific order, and stop at the first match. Set KW_DEBUG=1 before running a tool, to print the Java source that Klocwork selected.

Klocwork uses the bundled _jvm folder in the installation directory before KW_JAVA. In a default installation, KW_JAVA takes effect only if you remove the _jvm folder.

The bundled _jvm folder in the installation directory will be removed in a future release. Set KW_JAVA or JAVA_HOME now so that your configuration continues to work after you upgrade.

Validate server resolution order

The Validate server uses the following resolution order:

  1. The bundled _jvm folder in the installation directory
  2. KW_JAVA
  3. JAVA_HOME/JRE_HOME
  4. PATH

Windows resolution order

Set KW_JAVA for any tool to control which Java version Klocwork uses.

Set JAVA_HOME to the Java version that your build uses (for example, Ant, Maven, or Gradle). Otherwise, on PATH-only setups, Klocwork's own Java version can end up running the build, and the build specification might record the wrong compiler.

On Windows, Klocwork uses the following resolution order:

  • kwant:

    kwant does not use the Windows registry to find Java.
    1. The bundled _jvm folder in the installation directory
    2. KW_JAVA
    3. JAVA_HOME
    4. PATH
  • All other tools:

    1. The bundled _jvm folder in the installation directory
    2. KW_JAVA
    3. The Java installation registered in the Windows registry
    4. PATH

Linux resolution order

On Linux, Klocwork uses the following resolution order:

  1. The bundled _jvm folder in the installation directory
  2. The KW_JAVA environment variable which must point to the full path of the java executable, for example:

    export KW_JAVA=<your preferred JVM install directory>/java
  3. JAVA_HOME

  4. PATH