如何使用 installer4j (5.1.14) 中的安装程序变量在 .properties 文件中设置密钥

How to set a key in .properties file using installer variable in installer4j (5.1.14)

我正在尝试为我的应用程序构建一个安装程序,它询问端口号、应用程序数据目录等等。

我已尝试使用“替换文本文件中的安装程序变量”操作和可配置形式,其中的文本字段具有我想存储在 .properties 文件中的信息。

我尝试按照不同的方式将变量放入 .properties 文件,但没有成功。

http.port = ${portnum}  or
http.port = ${installer:portnum} or
http.port = portnum  

portnum 是文本字段的变量名称(它存储文本中给定的值),但代码的 none 在这里起作用。生成的文件具有相同的行,但没有从变量中获取值。

我想知道我哪里出错了。我是 install4j 的新手,因此不胜感激。提前致谢。

来自您的评论:

Yes I know. but in our project we are using Java 1.6 and install4j 6.0 requires minimum java 1.7.

只有 install4j IDE 是这样,但已安装的应用程序和最低版本为 1.6 的安装程序不是这样。因此,您应该可以使用 install4j 6 和 "Write properties to file" 操作。

否则语法

${installer:portnum}

如果定义了 portnum 变量,应该与 "Replace installer variable in text files" 操作一起工作。

我通过执行以下操作解决了问题...

我没有在屏幕上添加动作,而是在安装过程中添加了动作 "write text to a file" 并且我将变量添加为

http.port = ${installer:portnum} 

这解决了我的问题。感谢所有做出贡献的人。