Compiling and Running a Script as Part of a Package

When creating a Java Record Replay or a Java Vuser script, you may need to use methods in other classes in which the class or method is protected. If you try to compile this type of script, you will receive errors in the compilation stage indicating that the methods are inaccessible. To make sure that your script can access these methods, insert the package name containing these methods at the top of the script, just as you would do in a standard Java program— <package_name>. In the following example, the script defines the my.test package which consists of a path:

package my.test;
import lrapi.*;
public class Actions
{
    
}

In the above example, VuGen automatically creates the my/test folder hierarchy under the Vuser folder, and copies the Actions.java file to my/test/Actions.java, allowing it to compile with the relevant package. Note that the package statement must be the first line in the script, similar to Java (excluding comments).

Back to top