I have an application for which we use IzPack to create the installer. The installer is working fine in its current state, however, I need to add functionality that enables it to check whether an existing version of the software has been installed.
I understand IzPack supports this out of the box using its CheckedHelloPanel
, unfortunately that only works for Windows, as it appears to depend on the windows registry.
Is there a way to configure IzPack such that it is able to detect existing installations?
I need to be able to detect whether there is one and merely display a message notifying the user... Bonus points for how to give the user the option to trigger the uninstaller of the existing installation.
<validator>
, please include a code sample of the validator class, because I have considered this, but don't know where to startI wrote this to allow my application to be installed over the jboss install.
public class JBossChecker {
private static boolean tempJBossEnv;
private static boolean tempJBossDirectoryExists;
static {
String s = System.getenv("JBOSS_HOME");
tempJBossEnv= (s!=null);
if( tempJBossEnv) {
File f = new File(s);
tempJBossDirectoryExists= ( f.exists() && f.isDirectory());
}
hasJBossEnv =tempJBossEnv;
hasJBossDir = tempJBossDirectoryExists;
}
public static boolean hasJBossDir;
public static boolean hasJBossEnv;
public static void main(String[] args){
System.out.println("Jboss environment "+hasJBossEnv);
System.out.println("Jboss directory "+hasJBossDir);
}
}
Then the installer has a section like
<conditions>
<condition type="java" id="jbossEnv">
<java>
<class>au.com.codarra.ela.installer.JBossChecker</class
<field>hasJBossEnv</field>
</java>
<returnvalue type="boolean">true</returnvalue>
</condition>
<condition type="java" id="jbossDir">
<java>
<class>au.com.codarra.ela.installer.JBossChecker</class>
<field>hasJBossDir</field>
</java>
<returnvalue type="boolean">true</returnvalue>
</condition>
</conditions>
<installerrequirements>
<installerrequirement condition="jbossEnv" message="Your system does not have the environment variable JBOSS_HOME set. Cannot update your system. Is XXXX installed on this system?" />
<installerrequirement condition="jbossDir" message="Your system does not have a directory at the location in the environement variable JBOSS_HOME . Cannot update your system. Is XXXX installed on this system?" />
</installerrequirements>
<dynamicvariables>
<variable name="INSTALL_PATH" value="${ENV[JBOSS_HOME]}"/>
</dynamicvariables>
<jar src="c:\dev\xxxx\build\installer.jar" />
The bit at the end makes sure izpack adds it to the installer jar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With