## install4j API documentation

## com.install4j.api
Class Util

    java.lang.Object
      com.install4j.api.Util

    public class Util

extends java.lang.Object

The class contains various utility functions to be used by script properties, custom actions and custom screens.

Author:
  ej-technologies GmbH

Constructor Summary
`Util()`

Method Summary
`static void` | `dumpVariables(Context context)` Dump all defined installer variables to stderr.
`static void` | `fatalError(java.lang.Throwable t)` This method can be invoked if you encounter a non-recoverable and non-expected error in your custom code.
`static java.lang.String` | `getAnnotatedStackTrace(java.lang.Throwable t)` If a stack trace comes from scripts, it can be difficult to trace them to their origin by looking at the stack trace alone.
`static java.awt.Window` | `getParentWindow()` Get the window of the installer.
`static java.lang.String` | `getStandardApplicationsDirectory()` Returns the standard directory for installing applications.
`static java.lang.String` | `getUserHome()` Returns the home directory.
`static boolean` | `isAdminUser()` Checks whether the current user has administration privileges.
`static boolean` | `isHpux()` Returns whether the platform is HP UX.
`static boolean` | `isLinux()` Returns whether the platform is Linux.
`static boolean` | `isMacOS()` Returns whether the platform is Mac OS X.
`static boolean` | `isMacosInstaller()` Returns whether the installer is a Mac OS X installer
`static boolean` | `isSolaris()` Returns whether the platform is Solaris.
`static boolean` | `isUnixInstaller()` Returns whether the installer is a Unix installer
`static boolean` | `isWindows()` Returns whether the platform is Windows.
`static boolean` | `isWindows2000()` Returns whether the platform is Windows 2000.
`static boolean` | `isWindows9X()` Returns whether the platform is Windows 9X (95, 98, ME).
`static boolean` | `isWindowsInstaller()` Returns whether the installer is a Windows installer
`static boolean` | `isWindowsNT()` Returns whether the platform is Windows NT (not Windows 2000 and XP).
`static boolean` | `isWindowsVista()` Returns whether the platform is Windows Vista.
`static boolean` | `isWindowsXP()` Returns whether the platform is Windows XP.
`static void` | `logError(java.lang.Object source, java.lang.String message)` Writes an error message to the installation log.
`static void` | `logInfo(java.lang.Object source, java.lang.String message)` Writes an info message to the installation log.
`static void` | `printAnnotatedStackTrace(java.lang.Throwable t)` Prints the return value of `getAnnotatedStackTrace(Throwable)` to `System.err`.
`static void` | `showErrorMessage(java.lang.String message)` Show a message dialog.
`static void` | `showMessage(java.lang.String message)` Show a message dialog.
`static void` | `showMessage(java.lang.String message, int messageType)` Show a message dialog.
`static int` | `showOptionDialog(java.lang.String message, java.lang.String[] options, int messageType)` Show an options dialog.
`static void` | `showPath(java.lang.String path)` Show the specified directory or file.
`static void` | `showUrl(java.net.URL url)` Show a URL in the default browser.
`static void` | `showWarningMessage(java.lang.String message)` Show a message dialog.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Util

    public Util()

Method Detail

### getUserHome

    public static java.lang.String getUserHome()

  Returns the home directory. On Windows 2000/XP, the location of the My documents folder will be returned, rather than the value of `System.getProperty("java.home")`

  Returns:
    the home directory

### isSolaris

    public static boolean isSolaris()

  Returns whether the platform is Solaris.

  Returns:
    the result

### isLinux

    public static boolean isLinux()

  Returns whether the platform is Linux.

  Returns:
    the result

### isWindows

    public static boolean isWindows()

  Returns whether the platform is Windows.

  Returns:
    the result

### isWindows9X

    public static boolean isWindows9X()

  Returns whether the platform is Windows 9X (95, 98, ME).

  Returns:
    the result

### isWindowsNT

    public static boolean isWindowsNT()

  Returns whether the platform is Windows NT (not Windows 2000 and XP).

  Returns:
    the result

### isWindowsVista

    public static boolean isWindowsVista()

  Returns whether the platform is Windows Vista.

  Returns:
    the result

### isWindowsXP

    public static boolean isWindowsXP()

  Returns whether the platform is Windows XP.

  Returns:
    the result

### isWindows2000

    public static boolean isWindows2000()

  Returns whether the platform is Windows 2000.

  Returns:
    the result

### isMacOS

    public static boolean isMacOS()

  Returns whether the platform is Mac OS X.

  Returns:
    the result

### isHpux

    public static boolean isHpux()

  Returns whether the platform is HP UX.

  Returns:
    the result

### isWindowsInstaller

    public static boolean isWindowsInstaller()

  Returns whether the installer is a Windows installer

  Returns:
    the result

### isUnixInstaller

    public static boolean isUnixInstaller()

  Returns whether the installer is a Unix installer

  Returns:
    the result

### isMacosInstaller

    public static boolean isMacosInstaller()

  Returns whether the installer is a Mac OS X installer

  Returns:
    the result

### getStandardApplicationsDirectory

    public static java.lang.String getStandardApplicationsDirectory()

  Returns the standard directory for installing applications.

  Returns:
    the directory

### showUrl

    public static void showUrl(java.net.URL url)

  Show a URL in the default browser. If no default browser can be determined for the operating system, the user is asked to locate the executable of the internet browser. This executable is cached so that subsequent invocations of this method do not bring up this questions again.

  For quiet installers, this method does nothing.

  Parameters:
    `url` - the URL to be shown in the browser.

### showMessage

    public static void showMessage(java.lang.String message,
                                   int messageType)

  Show a message dialog. This message dialog is a JOptionPane, the parameters are equivalent to those of the standard Java class.

  Parameters:
    `message` - the message
    `messageType` - the message type (see JOptionPane)
  See Also:
    `JOptionPane`

### showMessage

    public static void showMessage(java.lang.String message)

  Show a message dialog. This message dialog is a JOptionPane with a message type of INFORMATION_MESSAGE.

  Parameters:
    `message` - the message
  See Also:
    `JOptionPane`

### showErrorMessage

    public static void showErrorMessage(java.lang.String message)

  Show a message dialog. This message dialog is a JOptionPane with a message type of ERROR_MESSAGE.

  Parameters:
    `message` - the message
  See Also:
    `JOptionPane`

### showWarningMessage

    public static void showWarningMessage(java.lang.String message)

  Show a message dialog. This message dialog is a JOptionPane with a message type of WARNING_MESSAGE.

  Parameters:
    `message` - the message
  See Also:
    `JOptionPane`

### showOptionDialog

    public static int showOptionDialog(java.lang.String message,
                                       java.lang.String[] options,
                                       int messageType)
                                throws UserCanceledException

  Show an options dialog. This option dialog is a JOptionPane, the parameters are equivalent to those of the standard Java class

  Parameters:
    `message` - the message
    `options` - the options
    `messageType` - the message type (see JOptionPane)
  Returns:
    the index of the selected option or -1 if the installer is running in unattended mode
  Throws:
    `UserCanceledException` - if the user cancels the selection
  See Also:
    `JOptionPane`

### fatalError

    public static void fatalError(java.lang.Throwable t)

  This method can be invoked if you encounter a non-recoverable and non-expected error in your custom code. The exception and all system properties will be printed to a log file and the user will be informed with a crash dialog. The installer will then quit.

  Parameters:
    `t` - the exception that ocurred

### getParentWindow

    public static java.awt.Window getParentWindow()

  Get the window of the installer.

  Returns:
    the window or `null` if the installer is silent

### logInfo

    public static void logInfo(java.lang.Object source,
                               java.lang.String message)

  Writes an info message to the installation log.

  Parameters:
    `source` - the object that requests the log. Can be null.
    `message` - the message to be logged.

### logError

    public static void logError(java.lang.Object source,
                                java.lang.String message)

  Writes an error message to the installation log.

  Parameters:
    `source` - the object that requests the log. Can be null.
    `message` - the message to be logged.

### dumpVariables

    public static void dumpVariables(Context context)

  Dump all defined installer variables to stderr. In order to be able to see the output you have to create a debug installer by selecting the corresponding option in the Build step in the install4j GUI.

  Parameters:
    `context` - the context

### isAdminUser

    public static boolean isAdminUser()

  Checks whether the current user has administration privileges.
  - On Windows NT/2000/XP this is the case, if the user is a member of the "Administrators" group.
  - On Windows Vista this method returns `true` if the installer is running with administration privileges. This can be specified by the user when starting the installer. Alternatively, you can request that the installers on Windows Vista always runs with administration privileges in the Windows media wizard in the install4j GUI.
  - On Windows 9x this method always returns `true`.
  - On Mac OS X this method returns `true` if the user is member of the "admin" group.
  - On Unix this method returns `true` if the current user is called "root".

  Returns:
    `true` or `false`.

### getAnnotatedStackTrace

    public static java.lang.String getAnnotatedStackTrace(java.lang.Throwable t)

  If a stack trace comes from scripts, it can be difficult to trace them to their origin by looking at the stack trace alone. With this method you can annotate the stack trace with the actual names of properties, actions, screens or form components that contain the offending script code.

  Parameters:
    `t` - the exception
  Returns:
    the annotated stack trace

### printAnnotatedStackTrace

    public static void printAnnotatedStackTrace(java.lang.Throwable t)

  Prints the return value of `getAnnotatedStackTrace(Throwable)` to `System.err`. This can be used for debugging purposes.

  Parameters:
    `t` - the exception

### showPath

    public static void showPath(java.lang.String path)

  Show the specified directory or file. On Windows this will open an explorer window, on OS X a finder window, on Linux/Unix it will open a terminal.

  Parameters:
    `path` - the directory that should be displayed