In IntelliJ I can run:
ImageIcon icon = new ImageIcon("src/de/therealjan/tools/pictures/pic.png");
But in a runnable JAR File that won't work. I already tried "/pictures/pic.png" but that doesn't work too.
Any ideas?
In IntelliJ I can run:
ImageIcon icon = new ImageIcon("src/de/therealjan/tools/pictures/pic.png");
But in a runnable JAR File that won't work. I already tried "/pictures/pic.png" but that doesn't work too.
Any ideas?
you should add the image in your classpath or a directory in your classpath and then load your image like this:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL resource = classLoader.getResource("src/de/therealjan/tools/pictures/pic.png");
ImageIcon icon = new ImageIcon(resource);