Calling Java classes from IzPack

久未见 提交于 2019-12-09 10:29:00

问题


How do you invoke a method from a Java class from IzPack? Static methods are OK, and I need to be able to pass it parameters.

Thank you!


Background info:

I am trying to write an IzPack installer which is able to detect a previously installed versions of the application. After finding out that it doesn't really support this feature (except in Windows), I think the only way to do this is through writing a Java class and calling it from IzPack.

Tim Williscroft has previously suggested this method, that reads the value of a static field of a class:

 <condition type="java" id="jbossEnv">
             <java> 
                 <class>au.com.codarra.ela.installer.JBossChecker</class
                 <field>hasJBossEnv</field>
             </java>
             <returnvalue type="boolean">true</returnvalue>
 </condition>

However, is it possible to call <java> from somewhere other than a <condition> tag? I want to be able to call it from a <variable> tag.
Also, is it possible to call a method from a Java class instead of reading a value of a field? I want to be able to pass parameters to my class.


回答1:


You can call static methods, but I don't think you can pass in parameters. You could create a new 'Condition type', but I have no experience with this so I can't confirm the flexibility it provides...

So, I don't have a direct response, but another suggestion which might help:

I tend to pass any complex post-processing on to separate processes.

Have you investigated the Processing panel? You can start any process, and pass in variables ..

e.g.

<processing>
  <job name="do xyz">
    <os family="windows" />
    <executefile name="$INSTALL_PATH/scripts/xyz.bat">
      <arg>doit</arg><arg>$variable</arg>
    </executefile>
  </job>
  <job name="do xyz">
    <os family="unix" />
    <executefile name="$INSTALL_PATH/scripts/xyz.sh">
      <arg>doit</arg><arg>$variable</arg>
    </executefile>
  </job>
</processing>

I've used it to set up services and start up immediately. That kind of thing. Just make sure your script exits cleanly, otherwise IzPack will hang.

See here: http://izpack.org/documentation/panels.html#processpanel




回答2:


Consider using the IzPack Ant integration

http://izpack.org/documentation/advanced-features.html#apache-ant-integration

and the Ant Java callout task

http://ant.apache.org/manual/Tasks/java.html




回答3:


Hello In the link below you will find a nice help about izpack installer.

http://www.imrantariq.com/blog/?p=89

Link below contains a detailed pdf to make installer with izpack.

http://www.imrantariq.com/blog/?attachment_id=112

cheers

Imran tariq




回答4:


I have successfully configured an IzPack installer that executes a "bat" file (with one parameter) during installation to generate a license request code. First I had to make sure that the bat file was copied to the user's chosen $INSTALL_PATH, and in the IzPack install.xml I added a ProcessPanel after the InstallPanel (which is where all the files, including the "bat" one, gets copied). My ProcessPanel.Spec.xml looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<izpack:processing version="5.0"
xmlns:izpack="http://izpack.org/schema/processing" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://izpack.org/schema/processing 
http://izpack.org/schema/5.0/izpack-processing-5.0.xsd">

<job name="initialize license">
  <executefile name="$INSTALL_PATH/initialize.bat" workingDir="$INSTALL_PATH" onError="fail">
    <arg>license</arg>
  </executefile>
</job>
<onFail previous="false" next="false" />
<onSuccess previous="false" next="true" />
</izpack:processing>


来源:https://stackoverflow.com/questions/2475527/calling-java-classes-from-izpack

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