JavaRuntime Object

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

Description

The JavaRuntime object provides access to Java virtual machines that exist in a Windows process. To obtain the object in tests, call the JavaRuntime method of the desired process object.

The JavaRuntime object is associated with an instance of the java.lang.Runtime class of the desired Java virtual machine. It contains the same properties and methods as java.lang.Runtime does, as well as specific properties provided by TestComplete. The objects’s JavaClasses property provides access to packages and classes defined within the Java application. Using this property you can access static non-visual objects and even create the application’s class instances directly from your script code. For more information about support for Java in TestComplete, see Testing Java Applications - Overview.

Members

Example

The code below obtains the desired Java class and its method by using the JavaRuntime object.

JavaScript, JScript

function JavaRuntime()
{
  // Obtains the JavaRuntime object
  var RunTime = Sys.Process("Java_App_Name").JavaRuntime;
  // Obtains the desired Java package
  var jPack = RunTime.JavaClasses.Package_Name;
  // Obtains the class
  var jClass = jPack.Class_Name;
  // Obtains the method
  var jMeth = jClass.Method_Name;
  // ...
}

Python

def JavaRuntime():

   # Obtains the JavaRuntime object
   RunTime = Sys.Process("Java_App_Name").JavaRuntime
   # Obtains the desired Java package
   jPack = RunTime.JavaClasses.Package_Name
   # Obtains the class
   jClass = jPack.Class_Name
   # Obtains the method
   jMeth = jClass.Method_Name
   # ...

VBScript

Sub JavaRuntime()

  ' Obtains the JavaRuntime object
  Set RunTime = Sys.Process("Java_App_Name").JavaRuntime
  ' Obtains the desired Java package
  Set jPack = RunTime.JavaClasses.Package_Name
  ' Obtains the class
  Set jClass = jPack.Class_Name
  ' Obtains the method
  Set jMeth = jClass.Method_Name
  ' ...
  
End Sub

DelphiScript

function JavaRuntime;
var RunTime, jPack, jClass, jMeth;
begin

  // Obtains the JavaRuntime object
  RunTime := Sys.Process('Java_App_Name').JavaRuntime;
  // Obtains the desired Java package
  jPack := RunTime.JavaClasses.Package_Name;
  // Obtains the class
  jClass := jPack.Class_Name;
  // Obtains the method
  jMeth := jClass.Method_Name;
  // ...
end;

C++Script, C#Script

function JavaRuntime()
{
  // Obtains the JavaRuntime object
  var RunTime = Sys["Process"]("Java_App_Name")["JavaRuntime"];
  // Obtains the desired Java package
  var jPack = RunTime["JavaClasses"]["Package_Name"];
  // Obtains the class
  var jClass = jPack["Class_Name"];
  // Obtains the method
  var jMeth = jClass["Method_Name"]();
  // ...
}

See Also

Testing Java Applications - Overview
JavaRuntime Method

Highlight search results