Packages
 In this topic

*Methods

 

Packages   PreviousThis PackageNext
Package com.ms.util   Previous This
Package
Next

 


Class SystemVersionManager

public class SystemVersionManager implements Runnable
{
  // Methods
  public static Properties createVersion (int major, int minor, int
        buildnum, int buildinc, String description);
  public static Enumeration enumerate ();
  public static Properties getPackageVersion (String pkgname);
  public static Properties getSystemComponentVersion (
        String compname);
  public static Properties getVMVersion ();
  public void run ();
}

This class provides methods that set and retrieve system version properties. Typically, this class is not called directly. Rather, it is used by implementing a VersionManager class that is derived from it. For a standard implementation of a VersionManager class, refer to the Samples\Version directory in the Microsoft SDK for Java. This class can be added, without editing, directly to your distributed packages. In doing so, applications can check the version information of the system components and your distributed classes. The VersionManager sample class works on any virtual machine, but the SystemVersionManager class is provided specifically for use with the Microsoft Win32 VM for Java.

When VersionManager methods are called, the VersionManager object first calls the SystemVersionManager methods to return system information. If the SystemVersionManager class returns nothing or does not exist, and the applet or application runs on the Microsoft VM, the sample implementation of the VersionManager class returns the information for the 3.0 release of Internet Explorer (since Internet Explorer 3.0 was the only version not to include SystemVersionManager). The package information retrieved by the VersionManager works in any virtual machine. The system information, of course, only works on the Microsoft VM.

You can request a package by name by using the getPackageVersion method. This method searches for the information in a Version (*.Version) class in the requested package or a superpackage. The version information is in a Properties object. All version objects have the following keys:

  • MajorVersion
  • MinorVersion
  • BuildNumber
  • BuildIncrement
  • Description

All values are stored as instances of Strings. You can also use getSystemComponentVersion to request information about the following system components:

  • VM
  • Classes
  • TrustedClasses

The following is an example of using the VersionManager class to retrieve the version of the Microsoft Virtual Machine for Java:


// vmver.java

import java.util.Properties;
import java.util.Enumeration;

public class vmver
{
    public static void main (String[] args)
    {
        try
        {
            Properties props = VersionManager.getSystemComponentVersion("VM");
            if (props == null)
            {
                System.out.println("Not a Microsoft VM.");
            }
            else
            {
                Enumeration e = props.keys();
                while (e.hasMoreElements())
                {
                    String prop = (String)e.nextElement();
                    System.out.println(prop+": "+props.get(prop));
                }
            }
        }
        catch (Throwable e)
        {
            System.out.println("unexpected error:");
            e.printStackTrace();
        }
    }
}

Methods

createVersion

public static Properties createVersion (int major, int minor, int buildnum,
        int buildinc, String description);

Creates a version object.

Return Value:

Returns a Property object that contains the version properties.

ParameterDescription
major The major version number.
minor The minor version number.
buildnum The build number.
buildinc The incremental build number.
description The string description of the version.

Remarks:

A typical example of this method is the following internal call to createVersion, which creates a version object for system classes before incremental build 1155.

createVersion(4, 79, 0, 1154, "Microsoft(R) System 
Classes, 3.0 Prerelease")

enumerate

public static Enumeration enumerate ();

Retrieves the default system components that are provided with the version information.

Return Value:

Returns an Enumeration object that contains the following String objects:

String
Description
VM
The VM version
Classes
The version of the system classes
TrustedClasses
The version of the classes in the TrustedLib path

getPackageVersion

public static Properties getPackageVersion (String pkgname);

Retrieves the version information for the specified package.

Return Value:

Returns a Properties object that contains the package version data.

ParameterDescription
pkgname The name of the package.

getSystemComponentVersion

public static Properties getSystemComponentVersion (String compname);

Retrieves the component version information.

Return Value:

Returns a Properties object that contains the version information.

ParameterDescription
compname The system component name, which can be one of the components returned by the enumerate method.

getVMVersion

public static Properties getVMVersion ();

Retrieves version data for the virtual machine (VM).

Return Value:

Returns a Properties object that contains the VM version data.

run

public void run ();

Runs when the thread originating in SystemVersionManager getSystemComponentVersion is started.

Return Value:

No return value.

Remarks:

This method retrieves the value of the ClassesBuild string in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Java VM registry key.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.