I’d like to preface this by saying I know close to nothing about Gradle.
Anyway, my program uses png files as part of questions and answers, it’s a quiz program testing the user’s ability on the topic of the quiz. Anyway, when I run the program normally in Intellij it works fine. After building the jar file and running it, the pictures don’t show up. I assume this has to do with hard coding the file path like so: new ImageIcon("./src/main/resources/name.png");
I brought this up to a friend and he suggested that I use this line of code instead:
new ImageIcon(Objects.requireNonNull(getClass().getClassLoader().getResource(“name.png”)));
So I put this new code in my program and now I get a Null Pointer error. I don’t know why that’s happening, could be because the program can’t find the file, for some reason. But any and all help is appreciated. Thank you!