我的项目构建文件夹有以下结构:
build
|-classes
|package
|-HelloWorld.class
|-resources
|-images
|-image.png
HelloWorld类中有ImageIcon对象,其声明应如下所示:
ImageIcon icon = new ImageIcon(HelloWorld.class.getResource("../../resources/images/picture.png"));
但它会在NullPointerException
方法中抛出getResource()
。我在哪里弄错了?