[英]install4j6: class.getClassLoader().getResourceAsStream(fileName) returns Null
I am making an installer for my application using install4j. 我正在使用install4j为我的应用程序制作安装程序。 Previously I used install4j-5 and now using install4j 6.0.1.
以前我使用install4j-5,现在使用install4j 6.0.1。
Below problem is with install4j 6.0.1 & Works fine with install4j5
下面的问题是install4j 6.0.1&install4j5正常工作
I am calling this from a static method 我是用静态方法调用它的
Class: Util.java resourcePkgPath- "SysConfig.conf" File in Different Package 类:Util.java resourcePkgPath-“SysConfig.conf”文件在不同的包中
public static InputStream getResourceAsStream(String resourcePkgPath)
{ return Util.class.getClassLoader().getResourceAsStream(resourcePkgPath);
public static InputStream getResourceAsStream(String resourcePkgPath)
{ return Util.class.getClassLoader().getResourceAsStream(resourcePkgPath);
} }
When I am running my application (ie from installer) then it gives me NullPointerException but when I run the same application from command line then it works perfectly fine.
当我运行我的应用程序(即从安装程序)然后它给我NullPointerException但是当我从命令行运行相同的应用程序时,它工作得很好。 Also it runs successfully from Eclipse.
它也可以从Eclipse成功运行。
If you add the root directory to the class path of the launcher, files in it can be loaded as a resource. 如果将根目录添加到启动程序的类路径,则可以将其中的文件作为资源加载。
In previous versions, the directory of the executable was mistakenly added to the class path by default, so that's why it used to work in your case. 在以前的版本中,默认情况下,可执行文件的目录被错误地添加到类路径中,因此这就是它在您的情况下工作的原因。
If both your launcher and the "com" directory are both directly in the installation directory, add the directory "." 如果启动程序和“com”目录都直接位于安装目录中,请添加目录“。” (without the quotes) to the class path configuration of your launcher.
(不带引号)到启动器的类路径配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.