Share this page

# Manually insert Java methods

You can use pre-defined Java packages within a Vuser script. The packages can be included in specific archive files or in the archive files contained in designated folders.

You can customize the function generation settings by modifying the recording options. For more information, see General > Script recording options.

To insert Java functions:

1. Click within your script at the required point of insertion.

2. Click Java Function in the toolbar. The Insert Java Function dialog box opens. Here you can add functions to your Vuser script.

   Packages, classes, methods, and other objects are represented by icons as follows:

   Icon | Item | Example
   --- | --- | ---
   | Package | java.util
   | Class | public class Hashtable extends java.util.Dictionary implements java.lang.Cloneable, java.io.Serializable
   | Interface class | public interface Enumeration
   | Method | public synchronized java.util.Enumeration keys ()
   | Static method | public static synchronized java.util.TimeZone getTimeZone
   | Constructor method | public void Hashtable ()

3. Under Locations, VuGen lists the paths and archives defined in the CLASSPATH environment variable

   To add a path, click Select Folder and then locate and highlight the required folder.

   To add an archive (jar or zip), click Select Library and then locate and highlight one or more archive files.

   Repeat for each path or archive you want to add.

4. Select or clear the check boxes to the left of each item in the Locations list. If an item is selected, its members are listed in the Packages list below.

5. Click Packages to close the Locations area and view the available packages.

   Tip: Click the arrows to the left of each item in the navigator, to expand or collapse the trees.

6. Select an object and click Insert. VuGen inserts the object at the location of the cursor in the script. To paste all the methods of a class into your script, select the class and click Insert.

   Repeat for all of the required methods or classes, and then click Close.

   Note: When you close the Insert Java Function dialog box, VuGen gives you the option to add the newly added locations to the Classpath list in the Java Environment runtime settings.

7. Modify the method parameter.

   If the script generation setting DefaultValues is set to true, you can use the default values inserted by VuGen.

   If DefaultValues is set to false, you must add parameters for all methods you insert into the script.

   In addition, modify any return values. For example, if your script generated the following statement:

   `"(String)=JavaVersion.getVersionId();"`

   replace (String) with a string type variable.

8. Add any necessary statements to your script, such as imports or Java-specific functions, from the Function Reference. For details, see Java Vuser protocol.

9. Save the script and run it from VuGen.

https://admhelp.microfocus.com VuGen,Professional Performance Engineering,Performance Engineering for Developers 8942
Tips to improve your search results... OpenText™ Virtual User Generator Help Center OpenText™ VuGen Help 26.1-26.3 All View Local Help Center View Online Help Center Version: