-1

I'm developing a java project for a university exam. The project involves the creation of an application with the JDBC methodology. The project is almost finished, I was dedicating myself to the aesthetic part and here the problems begin :( . I'm trying to put an icon to the application with the following instructions:

public MainFrame() {
        try {
            setIconImage(ImageIO.read(getClass().getResourceAsStream("/resources/icon.png")));
        } catch (IOException e) {
            System.out.println("Icon Image could not be loaded");
        }

The console gives me this:

java.lang.IllegalArgumentException: input == null!
    at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1358)
    at Boundary.MainFrame.<init>(MainFrame.java:52)
    at Boundary.MainFrame$1.run(MainFrame.java:38)

How can I fix?

1 Answers1

0

The resources folder does not exists inside the deliverable. You have to address it as it is in the root directory

setIconImage(ImageIO.read(getClass().getResourceAsStream("/icon.png")));
Jens
  • 67,715
  • 15
  • 98
  • 113
  • That *might* be the case (e.g. it would be in Maven). It depends on what was used to do the dev – g00se Jul 03 '23 at 12:34