从IzPack调用Java类 [英] Calling Java classes from IzPack

查看:87
本文介绍了从IzPack调用Java类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从IzPack的Java类中调用方法?静态方法可以,我需要能够传递参数.

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.

谢谢!

背景信息:

我正在尝试编写一个IzPack安装程序,该安装程序能够检测该应用程序以前安装的版本.在发现它确实不支持此功能(Windows除外)后,我认为实现此功能的唯一方法是编写Java类并从IzPack调用它.

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曾建议 此方法,它读取类的静态字段的值:

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>

但是,是否可以从<condition>标记之外的其他地方调用<java>?我希望能够从<variable>标签调用它.
另外,是否可以从Java类中调用方法而不是读取字段的值?我希望能够将参数传递给我的班级.

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.

推荐答案

您可以调用静态方法,但是我认为您不能传递参数. 您可以创建一个新的条件类型",但是我对此没有经验,所以我无法确认它提供的灵活性...

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

所以,我没有直接的答复,但是另一个建议可能会有所帮助:

我倾向于将任何复杂的后处理传递给单独的流程.

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

例如

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

我已使用它来设置服务并立即启动.那种事只需确保您的脚本干净退出即可,否则IzPack会挂起.

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.

请参阅此处: http://izpack.org/documentation/panels.html#processpanel

这篇关于从IzPack调用Java类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆