I have a fairly simple Java program going with the following structure:
/src/main/java/ (all the classes in here)
/src/main/resources (marked as resource root in IntelliJ, one png file in here)
/pom.xml
The way I build my Maven project is a bit of a workaround (because i couldn't get IntelliJ's artifact system to work). I have a run/debug configuration that builds the project using Command line: install
(hope I'm explaining that sufficiently well).
Everything works fine, except for the inclusion of the .png
file.
The weird thing is that the file is actually added to the executable jar
, but somehow the final program doesn't appear to use it at all. It's accessed via:
BufferedImage image = ImageIO.read(new File(getClass().getResource(url).toURI()));
Again, the final program works perfectly fine, except that the image is not visible at any point. Any help?
Edit: The png
is located in the root folder of the jar
, and the supplied URL is a string which is simply the name of the png
file. I should probably add that the program works fine in the IntelliJ-Run-environment (including the png
), but not using the executable jar
.