JVMInfo Property

Applies to TestComplete 15.62, last modified on March 19, 2024

Description

The JVMInfo property returns information on a Java Virtual Machine specified by its zero-based index among all Java Virtual Machines installed on your computer.

Declaration

JavaTestedAppObj.VMInfo(Index)

Read-Only Property A JVMInfo object
JavaTestedAppObj An expression, variable or parameter that specifies a reference to a JavaTestedApp object
Index [in]    Required    Integer    

Applies To

The property is applied to the following object:

Parameters

The property has the following parameter:

Index

Specifies the zero-based index of a Java Virtual Machine, information on which you want to get. To get the total number of Java Virtual Machines, use the JavaTestedApp.JVMCount property.

Property Value

A JVMInfo object containing information on the Java Virtual Machine.

Remarks

If you use Python or DelphiScript, you should enclose the parameter of the TestedApps.JavaTestedApp.JVMInfo property in square brackets: TestedApps.JavaTestedApp.JVMInfo[Index].

Example

The following example shows how you can get information on all Java Virtual Machines installed on your computer and how to configure a tested Java application to use a needed Java Virtual Machine:

Note: To run the example, you need to add a TestedApps item to your project.

JavaScript, JScript

function Test()
{

  // Adds a Java application to the project
  var ind = TestedApps.AddJavaApp();
  var app = TestedApps.Items(ind);

  // Gets information on installed Java virtual machines
  var count = app.JVMCount;
  if (count > 0)
  {

    // Posts information on installed Java virtual machines to the test log
    for (var i = 0; i < count; i++)
    {
      var jvm = app.JVMInfo(i);
      Log.AppendFolder(jvm.Executable);

      Log.Message("Version: " + jvm.Version);
      Log.Message("Description: " + jvm.Description);
      Log.Message("Is 64 Bit: " + jvm.Is64Bit);
      Log.Message("Runs with console: " + jvm.IsWithConsole);

      Log.PopLogFolder();
    }

    // Sets the Java application's launch parameters
    app.RunAsJar = true;
    app.JarFileName = "%Public%\\Documents\\TestComplete 15 Samples\\Desktop\\Orders\\swing\\orders.jar";

    // Sets the Java virtual machine executable that will launch the tested application
    app.JVMExecutable = app.JVMInfo(0).Executable;

  }
  else
  {
    Log.Message("No Java virtual machine is installed on your computer.");
  }

}

Python

def Test():
  
  # Adds a Java application to the project
  ind = TestedApps.AddJavaApp()
  app = TestedApps.Items[ind]

  # Gets information on installed Java virtual machines
  count = app.JVMCount
  if count > 0:

    # Posts information on installed Java virtual machines to the test log
    for i in range (0, count):
      jvm = app.JVMInfo[i]
      Log.AppendFolder(jvm.Executable)

      Log.Message("Version: " + jvm.Version)
      Log.Message("Description: " + jvm.Description)
      Log.Message("Is 64 Bit: " + aqConvert.VarToStr(jvm.Is64Bit))
      Log.Message("Runs with console: " + aqConvert.VarToStr(jvm.IsWithConsole))

      Log.PopLogFolder()

    # Sets the Java application's launch parameters
    app.RunAsJar = True
    app.JarFileName = "%Public%\Documents\TestComplete 11 Samples\Desktop\Orders\swing\orders.jar"

    # Sets the Java virtual machine executable that will launch the tested application
    app.JVMExecutable = app.JVMInfo[0].Executable

  else:
    Log.Message("No Java virtual machine is installed on your computer.")

VBScript

Sub Test

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

  ' Gets information on installed Java virtual machines
  count = app.JVMCount
  If count > 0 Then

    ' Posts information on installed Java virtual machines to the test log
    For i = 0 To count - 1
      Set jvm = app.JVMInfo(i)
      Log.AppendFolder(jvm.Executable)

      Log.Message("Version: " & jvm.Version)
      Log.Message("Description: " & jvm.Description)
      Log.Message("Is 64 Bit: " & jvm.Is64Bit)
      Log.Message("Runs with console: " & jvm.IsWithConsole)

      Log.PopLogFolder()
    Next

    ' Sets the Java application's launch parameters
    app.RunAsJar = true
    app.JarFileName = "%Public%\Documents\TestComplete 15 Samples\Desktop\Orders\swing\orders.jar"

    ' Sets the Java virtual machine executable that will launch the tested application
    app.JVMExecutable = app.JVMInfo(0).Executable

  Else
    Log.Message("No Java virtual machine is installed on your computer.")
  End If

End Sub

DelphiScript

procedure Test();
var app, jvm, ind, i, count;
begin

  // Adds a Java application to the project
  ind := TestedApps.AddJavaApp;
  app := TestedApps.Items[ind];

  // Gets information on installed Java virtual machines
  count := app.JVMCount;
  if count > 0 then
  begin

    // Posts information on installed Java virtual machines to the test log
    for i := 0 to count - 1 do
    begin
      jvm := app.JVMInfo[i];
      Log.AppendFolder(jvm.Executable);

      Log.Message('Version: ' + jvm.Version);
      Log.Message('Description: ' + jvm.Description);
      Log.Message('Is 64 Bit: ' + aqConvert.VarToStr(jvm.Is64Bit));
      Log.Message('Runs with console: ' + aqConvert.VarToStr(jvm.IsWithConsole));

      Log.PopLogFolder;
    end;

    // Sets the Java application's launch parameters
    app.RunAsJar := true;
    app.JarFileName := '%Public%\Documents\TestComplete 15 Samples\Desktop\Orders\swing\orders.jar';

    // Sets the Java virtual machine executable that will launch the tested application
    app.JVMExecutable := app.JVMInfo[0].Executable;

  end
  else
    Log.Message('No Java virtual machine is installed on your computer.');

end;

C++Script, C#Script

function Test()
{

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

  // Gets information on installed Java virtual machines
  var count = app["JVMCount"];
  if (count > 0)
  {

    // Posts information on installed Java virtual machines to the test log
    for (var i = 0; i < count; i++)
    {
      var jvm = app["JVMInfo"](i);
      Log["AppendFolder"](jvm["Executable"]);

      Log["Message"]("Version: " + jvm["Version"]);
      Log["Message"]("Description: " + jvm["Description"]);
      Log["Message"]("Is 64 Bit: " + jvm["Is64Bit"]);
      Log["Message"]("Runs with console: " + jvm["IsWithConsole"]);

      Log["PopLogFolder"]();
    }

    // Sets the Java application's launch parameters
    app["RunAsJar"] = true;
    app["JarFileName"] = "%Public%\\Documents\\TestComplete 15 Samples\\Desktop\\Orders\\swing\\orders.jar";

    // Sets the Java virtual machine executable that will launch the tested application
    app["JVMExecutable"] = app["JVMInfo"](0)["Executable"];

  }
  else
  {
    Log["Message"]("No Java virtual machine is installed on your computer.");
  }

}

See Also

JavaTestedApp Object
Testing Java Applications
Java Application Parameters

Highlight search results