install4j6: class.getClassLoader().getResourceAsStream(文件名) returns 空
install4j6: class.getClassLoader().getResourceAsStream(fileName) returns Null
我正在使用 install4j 为我的应用程序制作安装程序。
以前我用的是install4j-5,现在用的是install4j 6.0.1.
Below problem is with install4j 6.0.1 & Works fine with install4j5
我是从静态方法调用它的
Class: Util.java
resourcePkgPath- "SysConfig.conf" 不同包中的文件
public static InputStream getResourceAsStream(String resourcePkgPath)
{
return Util.class.getClassLoader().getResourceAsStream(resourcePkgPath);
}
When I am running my application (i.e. from installer) then it gives me NullPointerException but when I run the same application from command line then it works perfectly fine. Also it runs successfully from Eclipse.
如果将根目录添加到启动器的class路径,则可以将其中的文件作为资源加载。
在以前的版本中,默认情况下,可执行文件的目录被错误地添加到 class 路径中,所以这就是它在您的情况下起作用的原因。
如果你的启动器和"com"目录都直接在安装目录下,添加目录“.” (不带引号)到启动器的 class 路径配置。
我正在使用 install4j 为我的应用程序制作安装程序。 以前我用的是install4j-5,现在用的是install4j 6.0.1.
Below problem is with install4j 6.0.1 & Works fine with install4j5
我是从静态方法调用它的
Class: Util.java resourcePkgPath- "SysConfig.conf" 不同包中的文件
public static InputStream getResourceAsStream(String resourcePkgPath)
{
return Util.class.getClassLoader().getResourceAsStream(resourcePkgPath);
}
When I am running my application (i.e. from installer) then it gives me NullPointerException but when I run the same application from command line then it works perfectly fine. Also it runs successfully from Eclipse.
如果将根目录添加到启动器的class路径,则可以将其中的文件作为资源加载。
在以前的版本中,默认情况下,可执行文件的目录被错误地添加到 class 路径中,所以这就是它在您的情况下起作用的原因。
如果你的启动器和"com"目录都直接在安装目录下,添加目录“.” (不带引号)到启动器的 class 路径配置。