JVMInfo Object

Applies to TestComplete 14.0, last modified on January 23, 2019

Description

The JVMInfo object provides information on a Java Virtual Machine installed on your computer. To get the object in tests, use the TestedApps.JavaTestedApp.JVMInfo(Index) property, where Index is a zero-based index of the needed Java Virtual Machine among other installed Java Virtual Machines.

Members

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 14 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 14 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 14 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 14 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

Testing Java Applications - Overview
JVMCount Property
JVMInfo Property

Highlight search results