The Java Record Replay protocol enables full VuGen functionality when recording a script on a Java application or applet. VuGen creates a script in pure Java and enhances it with Java-specific functions.
In order to successfully record a script, you must install JDK on the VuGen machine before recording a script. JRE alone is insufficient. Ensure that the classpath and path environment variables are set according to the JDK installation instructions.
In addition, set the VuGen Java VM and Classpath run-time settings under Java Environment.
To replay with a 64-bit JDK, in the run-time settings, specify the JDK path in Java VM and select the check-box Miscellaneous->Replay script with 64-bit.
After recording, you can enhance or modify the script with standard Java code using JDK libraries or custom classes. VuGen utilizes the standard Java compiler, javac.exe, to compile the script. Once the script is successfully compiled you can incorporate it into a LoadRunner scenario or Business Process Monitor configuration.
Although .NET-based and Java protocols support creating threads, we recommend that you do not use background threads in real load testing scenarios because:
- Threads can degrade tests scalability
- Threads can affect performance measurements.
- The utility functions' behavior is undetermined if called from any thread except the Vuser main thread, which runs the vuser_init, Action and vuser_end actions. This applies to all functions named lr*.
Supported Java Communication Protocols
VuGen supports a variety of different communication protocols for Java applications:
- RMI: For information on the RMI protocol, see Working with RMI.
- CORBA: For information on the CORBA protocol, see Working with CORBA.
- JACADA: For information on the Jacada protocols, see Working with Jacada.
VuGen's built-in support for the Java protocols utilizes hook files to define how different classes communicate with each other. For information on the hook file structure, see Hook File Structure.
For recording, the JRE is selected by the recorded application configuration.
For code generation, the following methods are used to select the JRE. Each method is attempted in the order given, and the first to succeed is used.
- Use the LR_JAVA_HOME environment variable. You create this variable if you want to use it to select the JRE.
- Use the same JRE used for recording.
- The code generation infrastructure searches for a java.exe using the default Windows application search algorithm. The user has no control over which JRE is used.
By default, VuGen only records client side activity in a script, which then emulates the load on the server. You must edit the hook file to change the actions recorded by VuGen. To manually edit the hook file, see Java Custom Filters Overview.
Note: If you are recording a script that does not use one of the supported protocols (RMI, CORBA, JMS, Jacada), you must define your own hook file otherwise your Vuser script will be empty.
VuGen provides a tool that enables you to convert a script created for Web, into Java. For more information, see How to Convert a Web - HTTP/HTML Vuser Script into a Java Vuser Script.
Note: By default, Java 7 enables the Java Split Verifier. This prevents Java recording. VuGen uses the -XX:-UseSplitVerifier key while initializing the JVM during recording, to disable the verifier. This adaptation does not require any user intervention.