Share this page

# Java Syntax

## Importing the Class

To use Java calls in a VuGen script without specifying the full class path, put an include statement at the beginning of the action. For example, to use web and utility functions, put this line at the beginning of the action:

import lrapi.lr;

import lrapi.web;

Without these statements, you will have to specify the parent class:

lrapi.web.url...

lrapi.lr.log_message...

With the statements, you do not need the parent class:

web.url...

lr.log_message...

## Differences between C Syntax and Java Syntax

Java calls are different from C language calls in three important ways: string arguments are constructed differently, Java actions require an exception block, and the list argument syntax is different.

### String Arguments

Enclose literal strings in quotation marks. Variables are not enclosed in quotation marks. To append a variable or the return value of a function to a string, use the "+" sign. For example:

int i = 10;

lr.message("String with variable i = " + i +

", and parameter User = " + lr.eval_string("<User>"));

Output:

Notify: Parameter Substitution: parameter "User" = "Harold"

String with variable i = 10, and parameter User = Harold

### Exception Blocks

All Java methods throw exceptions, and will not compile unless enclosed in a try-catch block.

try

{

lrapi.web.save_header(lrapi.web.RESPONSE,

"response header");

/* ........ Other calls .........*/

}

catch (Exception e) {}

### Argument Lists

The syntax of the argument list is different from the C syntax, as explained in Java Argument List.

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: