Hopefully someone can help me with something that is probably very simple. I'm new to Java coding (2 weeks in), and using Eclipse IDE under Linux. I'm currently in the process of creating a JFrame application, everything so far is going well.
I have one little snag though - I have included a set of Icons and assigned them to a JLabel, and have them displayed. Upon exporting an Executable JAR, they are not in the JAR as a resource. If I open the JAR file, I can see the Images, in the ROOT of the JAR, not organized in their respective folders. (icons/, etc).
TL;DR - How do I import resources, in their folders, into a JAR as a resource.
public void drawCategoryIcons() {
for (int i = 0; i < aspCategories.length; i++) {
Icon pcIcon = new ImageIcon(getClass().getResource( "/icons/" + cats[i]));
aspCategories[i] = new JLabel("", JLabel.CENTER);
aspCategories[i].setIcon(pcIcon);
panel.add(aspCategories[i], "w 200, center");
}
}
If I RUN the project within Eclipse, everything works as it should. Exporting it, I get tons of errors.