// This is example code for the install4j API
// Please feel free to adapt it for your own purposes.

import com.install4j.api.InstallerContext;
import com.install4j.api.StartupHandler;
import com.install4j.api.Util;

import javax.swing.*;

// Startup handler that checks whether the target platform
// is a Windows 9x version. If yes, it will refuse to run
// the installer.
//
// An startup handler can be registered on the "Advanced tasks"
// tab of the installer section in the install4j GUI.
public class NoWin9XStartupHandler extends StartupHandler {

    // This method is called by the framework before the installer is displayed
    // or the unattended installer is run. If false is returned, the installer
    // is not executed.
    public boolean prepareInstaller(InstallerContext context) {
        // The Util class has utility methods for checking the platform.
        if (Util.isWindows9X()) {
            // For the unattended installer, we do not display a dialog box.
            if (!context.isUnattended()) {
                Util.showMessage("Cannot install this application on Windows 9x", JOptionPane.ERROR_MESSAGE);
            }
            // Returning false prevents the installer from running
            return false;
        } else {
            // Everything ok, proceed with the installation
            return true;
        }
    }
}
