Compile and Run a Script as Part of a Package

When creating 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>.

Example:  

This script defines the my.test package which consists of a path. Not that the package statement must be the first line in the script, similar to Java (excluding comments).

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

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.

Back to top