Set up the Java environment for Java protocols

This topic describes how to set up your Java environment for compilation when working with Java protocols.

About the Java environment

In order to work successfully with any of the Java protocols, you should install a supported JDK on the VuGen machine. Running a script involves compilation and replay, so a full JDK is required (a JRE alone is insufficient).

VuGen installation currently includes the following JDK versions:

  • Windows (VuGen, load generators): OpenJDK 11, 32-bit
  • Linux: OpenJDK 8, 32-bit (Linux)

However, it is recommended that you use your own (custom) JDK installation, appropriate for your testing environment. See the JDK support matrix for supported versions.

By default, the internal VuGen JRE installation is used for code generation. You can configure VuGen to instead use your custom JRE installation for code generation.

Follow the instructions in Setting up the Java environment, below to configure the environment.

Once the environment is set up, you can enhance or modify your Java script with standard Java code using JDK libraries or custom classes. VuGen utilizes the standard Java compiler, javac.exe, to compile the script.

After the script is successfully compiled, you can incorporate it into a LoadRunner Professional scenario or Business Process Monitor configuration.

Setting up the Java environment

Install the JDK and configure runtime settings for the Java protocol, as described in the following steps.

To set up the Java environment:

  1. Install the JDK. For information about supported versions, see the JDK support matrix.
  2. If you want to use the custom JRE for code generation, select Tools > Options > Scripting > Java > JRE > Custom JRE path, and define the path to the custom JRE folder.

    Note: This sets the custom JRE to be used for code generation and other actions for all VuGen protocols, not just Java protocols.

  3. In your Java protocol script, specify the JDK to use during replay. In Runtime Settings > Java Environment > Java VM:

    • Leave use internal logic to locate the JDK (default) selected to instruct VuGen to locate the JDK. When more then one JDK is installed on the machine, VuGen selects the first one found. The search order is as follows:

      1. Windows registry
      2. JAVA_HOME environment variable
      3. Path environment variable
    • Alternatively, select Use the specified JDK and enter the path to the JDK installation.
  4. You can define additional Java parameters for script replay in Runtime Settings > Java Environment > Java VM > Additional VM parameters.
  5. Set the classpath to the Java classes in Runtime Settings > Java Environment > Classpath. These files are then used as a reference, but are not contained in the script's folder.
  6. For Java Record Replay and Java Vuser scripts: If you are using a 64-bit JDK for replay, in the Runtime Settings select General > Miscellaneous > Replay script with 64-bit.

Note: If additional files are required during replay, add them as follows: In the Solution Explorer pane, right click the Extra Files node and select Add Files to Script. The files are copied to the script's folder.

Back to top