我的第一个问题:
几天来我一直试图弄清楚这一点,但我到了失去耐心的地步。以下是一些代码和我的项目结构。
问题:我怎样才能getResources()
在 eclipse 中工作并在被导入 jar 之后?
谢谢您的帮助。
public enum Icons {
XXX("src/resoruces/icons/xyz.png");
private ImageIcon icon;
Icons(String path) {
try {
// will fail miserably in eclipse and after exporting to jar
URL imageURL = getClass().getClassLoader().getResource(path);
icon = new ImageIcon(imageURL);
} catch (Exception e) {
// works like a char in eclipse and after creating the jar file
// with the files in the same directory
System.out.println("getResoruce() did not work");
icon = new ImageIcon(path);
}
}