gpt4 book ai didi

java - Install4j 常量导致构建失败

转载 作者:太空宇宙 更新时间:2023-11-04 12:14:39 25 4
gpt4 key购买 nike

不确定其他人是否遇到过此错误,但我正在更新现有的 Install4j 安装项目。我注意到每当使用 install4j 的上下文时,都会直接使用字符串。例如:

context.setVariable("somekey", "Some value");

我认为将“somekey”移动到一个 java 类中会很棒,其中可以在 install4j 和 java 代码中共享常量。

我创建了一个像这样的类:

public class InstallerContextConstants {
public static String KEY = "STRING_KEY";
}

所以我将其添加到屏幕的预激活脚本中,如下所示:

import com.somepackage.InstallerContextConstants;
Util.showMessage(InstallerContextConstants.APPLICATION_ONLY_INSTALL);

但是这不会编译...?它给了我:

install4j: compilation failed. Reason: com.ejt.a.c.g: Failed to compile script
----------
In application "Installer", property "Help customizer script":
1. WARNING in /private/var/folders/n7/vjsf1vp56s13hzpgypthp2_h0000gp/T/script4119340027951579520.java.dir/com/install4j/script/I4jScript_Internal_1.java (at line *19)
private void eval(final com.install4j.api.context.InstallerContext context, final java.util.List options) throws Exception {
^^^^^^^^^^^^^^
List is a raw type. References to generic type List<E> should be parameterized
----------
In application "Installer", property "Help customizer script":
2. WARNING in /private/var/folders/n7/vjsf1vp56s13hzpgypthp2_h0000gp/T/script4119340027951579520.java.dir/com/install4j/script/I4jScript_Internal_1.java (at line 1)
if (Util.isLinux()) options.add(new String[] { "--skip-precheck", "Bypasses Installer precheck checks. Note this must be the *first* argument."});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E> should be parameterized
----------
In application "Installer", property "Help customizer script":
3. WARNING in /private/var/folders/n7/vjsf1vp56s13hzpgypthp2_h0000gp/T/script4119340027951579520.java.dir/com/install4j/script/I4jScript_Internal_1.java (at line *24)
eval((com.install4j.api.context.InstallerContext)parameters[0], (java.util.List)parameters[1]);
^^^^^^^^^^^^^^
List is a raw type. References to generic type List<E> should be parameterized
----------
----------
In screen "[Additional confirmations]", property "Pre-activation expression":
4. ERROR in /private/var/folders/n7/vjsf1vp56s13hzpgypthp2_h0000gp/T/script4119340027951579520.java.dir/com/install4j/script/I4jScript_Internal_35.java (at line 5)
Util.showMessage(InstallerContextConstants.KEY);
^^^^^^^^^^^^^^^^^^^^^^^^
KEY cannot be resolved or is not a field
----------
4 problems (1 error, 3 warnings)

但是,如果我使用任何 install4j 字符串常量,它就可以工作。 http://resources.ej-technologies.com/install4j/help/javadoc/constant-values.html

关于如何做到这一点有什么建议吗?

最佳答案

原则上,您的方法应该有效,我猜想在安装程序->自定义代码和资源下尚未添加正确的编译类。

但是,在“安装程序”->“自定义代码和资源”步骤中单击“编辑代码”要容易得多,这将打开一个可用于所有脚本的静态定义编辑器。

如果添加

static String KEY = "STRING_KEY";

在那里,您可以在任何脚本中使用KEY而无需任何导入:

context.setVariable(KEY, "Some value");

关于java - Install4j 常量导致构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39539858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com