5

我有一个应用程序,我们使用IzPack为其创建安装程序。安装程序在其当前状态下工作正常,但是,我需要添加功能,使其能够检查是否已安装现有版本的软件。

我了解 IzPack 使用它的 支持开箱即用CheckedHelloPanel,不幸的是,它仅适用于 Windows,因为它似乎依赖于 Windows 注册表。

有没有办法配置 IzPack 使其能够检测现有安装

我需要能够检测是否有一个并且只显示一条消息通知用户......如何为用户提供触发现有安装的卸载程序的选项的奖励积分。


  • 假设软件将仅使用新的安装程序安装
  • 仅限 IzPack:请不要提出替代方案,因为我们现在无法更改
  • 如果您建议使用<validator>,请包含验证器类的代码示例,因为我已经考虑过这一点,但不知道从哪里开始
4

2 回答 2

2

我写这个是为了让我的应用程序可以通过 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);

 }
}

然后安装程序有一个类似的部分

<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" />

最后的位确保 izpack 将其添加到安装程序 jar 中。

于 2010-01-12T03:28:43.463 回答
0

它仅适用于 Windows,因为只有 Windows 具有注册表。但是,在 Linux 应用程序中,传统上没有自定义的统一位置。例如,您的运行脚本将放在 bin 文件夹中,您的二进制文件将放在 /opt 中,您的文档将放在 /var 中,等等。用户选择并包含一个“your-app”目录的想法与应用程序相关的一切都是 Windows 概念。

所以无论如何,在 Linux 中解决这个问题的方法是将应用程序的各个部分安装在非用户定义的位置。这样,如果您的应用程序已经安装,您就可以准确地知道它的位置。

于 2009-12-17T20:30:28.543 回答