Folks,
I am developing a Java application using Eclipse. Maven is used to create the final jar file.
In the application, I use some image icons for the buttons. Following some instructions on the Internet, I created a "source" directory by clicking on the project. I named the source directory as "res" and moved my images to this directory.
public static ImageIcon getIcon() {
if (isThisJarfile()) {
URL url = this.class.getResources("/res/myicon.png");
return new ImageIcon(url);
}else {
return new ImageIcon("/res/myicon.png");
}
}
This works fine when the app is not packaged as a jar file (great for debugging). However, when maven packages it, I see that the images are put in the root directory of the jar file. The following call works:
URL url = this.class.getResource("/myicon.png");
I am wondering if there is some step that I overlooked.
Note that I didn't have to do anything special to pom.xml for the images. Maven automatically picked them up (except that it is putting them in the wrong location).
Thank you in advance for your help.
Regards, Peter