无法创建相对路径

时间:2013-08-16 13:17:03

标签: java swing relative-path

我的项目构建文件夹有以下结构:

build
  |-classes
        |package
             |-HelloWorld.class
  |-resources
        |-images
              |-image.png

HelloWorld类中有ImageIcon对象,其声明应如下所示:

ImageIcon icon = new ImageIcon(HelloWorld.class.getResource("../../resources/images/picture.png"));

但它会在NullPointerException方法中抛出getResource()。我在哪里弄错了?

0 个答案:

没有答案
相关问题