How to get IzPack tocheck for an existing version of the software?

百般思念 提交于 2019-12-04 08:57:37
Tim Williscroft

I 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.

It only works on Windows, because only Windows has a registry. However, in Linux apps traditionally don't have customized unified locations. For example your run scripts would go in a bin folder, your binaries would go in /opt, your documentation would go in /var, etc. The idea that there's one single "your-app" directory that is selected by the user and contains everything related to the application is a Windows concept.

So anyway, the way to solve this in Linux is to install the various parts of your app in non-user-defined locations. That way you know exactly where your app would be if it was already installed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!