从 IzPack 调用 Java 类

发布于 2024-08-25 23:14:20 字数 914 浏览 9 评论 0原文

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

谢谢你!


背景信息:

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

Tim Williscroft 之前有建议 此方法读取类的静态字段的值:

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

但是,是否可以从 之外的其他位置调用 标签?我希望能够从 标记调用它。
另外,是否可以从 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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

旧情别恋 2024-09-01 23:14:20

您可以调用静态方法,但我认为您不能传入参数。
可以创建一个新的“条件类型”,但我没有这方面的经验,所以我无法确认它提供的灵活性...

所以,我没有直接回应,但另一个可能有帮助的建议:

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

您调查过处理面板吗? 您可以启动任何进程,并传入变量..

例如,

<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 将挂起。

参见这里:
http://izpack.org/documentation/panels.html#processpanel

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

花开半夏魅人心 2024-09-01 23:14:20

你好
在下面的链接中,您将找到有关 izpack 安装程序的很好的帮助。

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

链接如下包含使用 izpack 制作安装程序的详细 pdf 文件。

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

伊姆兰 干杯塔里克

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

心头的小情儿 2024-09-01 23:14:20

我已成功配置 IzPack 安装程序,该安装程序在安装过程中执行“bat”文件(带有一个参数)以生成许可证请求代码。首先,我必须确保将bat文件复制到用户选择的$INSTALL_PATH,并且在IzPack install.xml中,我在InstallPanel之后添加了一个ProcessPanel(这是复制所有文件,包括“bat”文件的地方) )。我的 ProcessPanel.Spec.xml 如下所示:

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

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文