RunAsJar Property

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

The RunAsJar property specifies whether the Java application should be launched from its executable .jar file or from the specified entry point.

If the application is to be launched from the executable .jar file, use the JarFileName property to specify the path to the desired file. Otherwise, use the JavaTestedApp.EntryPoint property to specify the application’s entry point and the JavaTestedApp.ClassPaths property to specify the path to the file containing the application’s main class.

Declaration

JavaTestedAppObj.RunAsJar

Read-Write Property Boolean
JavaTestedAppObj An expression, variable or parameter that specifies a reference to a JavaTestedApp object

Applies To

The property is applied to the following object:

Property Value

True if the application is launched from the .jar file, and False otherwise.

Remarks

If you assign a value to this property, TestComplete will treat your project as modified. So, you will need to save or cancel changes when closing the project. The specified value will be displayed in the TestedApps editor.

Example

The following example adds a new Java application to a project, specifies its launch parameters and then launches the application:

JavaScript, JScript

function Test()
{
  // Add a Java application to the project
  var ind = TestedApps.AddJavaApp();
  var app = TestedApps.Items(ind);

  // Specify Java application's launch parameters
  app.RunAsJar = false;
  app.JVMExecutable = "C:\\Program Files\\Java\\jre7\\Bin\\java.exe";
  app.EntryPoint = "com.automatedqa.testcomplete.OrdersApp";
  app.ClassPaths = "C:\\JavaApps\\SampleApp.jar" + "\r\n" + "C:\\JavaApps\\CustomClasses\\";
  app.Options = "-verbose:class";

  // Launches the Java application
  app.Run();
  // Test the application
  …

  app.Close();
}

Python

def Test():
  # Add a Java application to the project
  ind = TestedApps.AddJavaApp()
  app = TestedApps.Items[ind]
  # Specify Java application's launch parameters
  app.RunAsJar = False
  app.JVMExecutable = "C:\\Program Files\\Java\\jre7\\Bin\\java.exe"
  app.EntryPoint = "com.automatedqa.testcomplete.OrdersApp"
  app.ClassPaths = "C:\\JavaApps\\SampleApp.jar" + "\r\n" + "C:\\JavaApps\\CustomClasses\\"
  app.Options = "-verbose:class"
  # Launches the Java application
  app.Run();
  # Test the application
  # ...
  # app.Close()

VBScript

Sub Test
  ' Add a Java application to the project
  ind = TestedApps.AddJavaApp
  Set app = TestedApps.Items(ind)

  ' Specify Java application's launch parameters
  app.RunAsJar = false
  app.JVMExecutable = "C:\Program Files\Java\jre7\Bin\java.exe"
  app.EntryPoint = "com.automatedqa.testcomplete.OrdersApp"
  app.ClassPaths = "C:\JavaApps\SampleApp.jar" + vbCrLf + "C:\JavaApps\CustomClasses\"
  app.Options = "-verbose:class"

  ' Launches the Java application
  app.Run
  ' Test the application
  …

  app.Close
End Sub

DelphiScript

procedure Test();
var
  ind : integer;
  app : OleVariant;
begin
  // Add a Java application to the project
  ind := TestedApps.AddJavaApp();
  app := TestedApps.Items(ind);

  // Specify Java application's launch parameters
  app.RunAsJar := false;
  app.JVMExecutable := 'C:\Program Files\Java\jre7\Bin\java.exe';
  app.EntryPoint := 'com.automatedqa.testcomplete.OrdersApp';
  app.ClassPaths := 'C:\\JavaApps\\SampleApp.jar' + #10#13 + 'C:\JavaApps\CustomClasses\';
  app.Options := '-verbose:class';

  // Launches the Java application
  app.Run;
  // Test the application
  …

  app.Close;
end;

C++Script, C#Script

function Test()
{
  // Add a Java application to the project
  var ind = TestedApps["AddJavaApp"]();
  var app = TestedApps["Items"](ind);

  // Specify Java application's launch parameters
  app["RunAsJar"] = false;
  app["JVMExecutable"] = "C:\\Program Files\\Java\\jre7\\Bin\\java.exe";
  app["EntryPoint"] = "com.automatedqa.testcomplete.OrdersApp";
  app["ClassPaths"] = "C:\\JavaApps\\SampleApp.jar" + "\r\n" + "C:\\JavaApps\\CustomClasses\\";
  app["Options"] = "-verbose:class";

  // Launches the Java application
  app["Run"]();
  // Test the application
  …

  app["Close"]();
}

See Also

JavaTestedApp Object
Testing Java Applications
Java Application Parameters
EntryPoint Property
ClassPaths Property
JarFileName Property

Highlight search results