我正在尝试从项目中的类访问 Eclipse 项目中的文件。我需要将该项目声明为 jigsaw 模块才能从其他项目访问它,但是通过这样做,我无法再访问项目中的“example.png”等文件。
这是我的项目结构:
project/
module-info.java
src/
... # trying to access files from here
rsc/
icons/
example.png # this is the file I need
other-example.png
我的 module-info.java 看起来像这样:
module dice_engine {
exports com.packages.in.src;
requires java.desktop;
requires java.logging;
requires javafx.graphics;
requires javafx.controls;
}
我尝试像这样读取文件:
getClass().getClassLoader().getResourceAsStream("icons/example.png")
注意
- 我将 rsc 目录添加为源文件夹以在 Eclipse 中构建路径
- 在创建 module-info.java 之前这是可能的
- other-example.png 仍然可以访问
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)