JVMCount Property

Applies to TestComplete 15.0, last modified on October 22, 2021

Description

The JVMCount property returns the number of Java Virtual Machines installed on your computer.

Declaration

JavaTestedAppObj.JVMCount

Read-Only Property Integer
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

An integer value that specifies the number of installed Java Virtual Machines.

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