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.
Install the JDK and configure runtime settings for the Java protocol, as described in the following steps.
To set up the Java environment:
- Install the JDK. For information about supported versions, see the JDK support matrix.
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.
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:
- Windows registry
- JAVA_HOME environment variable
- Path environment variable
- Alternatively, select Use the specified JDK and enter the path to the JDK installation.
- You can define additional Java parameters for script replay in Runtime Settings > Java Environment > Java VM > Additional VM parameters.
- 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.
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.