To prepare Vuser scripts using Java code, use the Java type Vusers. This Vuser type supports Java on a protocol level. The Vuser script is compiled by a Java compiler and supports all of the standard Java conventions. For example, you can insert a comment by preceding the text with two forward slashes "//".
Java Record Replay Protocol explains how to create a script through recording using the Java Record Replay Vuser. To prepare a Java coded script through programming, see the following sections.
The first step in creating a Java compatible Vuser script, is to create a new Vuser script template of the type Java Vuser. Then, you program or paste the desired Java code into the script template. You can add Java Vuser functions to enhance the script and parameterize the arguments to use different values during iterations.
The Java Vuser script runs as a scalable multi-threaded application. If you include a custom class in your script, make sure that the code is thread-safe. Code that is not thread-safe may cause inaccurate results. For code that is not thread-safe, run the Java Vusers as processes. This creates a separate Java Virtual Machine for each process, resulting in a script that is less scalable.
After you prepare a script, run it as a standalone test from VuGen. A Java compiler (javac), checks it for errors and compiles the script.
After you create a script, you integrate it into your environment: a LoadRunner scenario, Performance Center load test, or Business Process Monitor configuration.