Home > Software engineering >  Exporting JAR file from Eclipse doesn't include folders/files outside src
Exporting JAR file from Eclipse doesn't include folders/files outside src

Time:06-02

I am trying to export a jar file using eclipse but it doesn't include any folder or file outside the src. I have an images folder and 2 csv files that I need to be in the jar file so the images can be displayed and for the csv files to be loaded. When I run in eclipse the images are displayed and the csv files are loaded but when I export as jar file they don't.

background.setIcon(new ImageIcon("images\\marvel_800_500.png"));

This is how I'm setting the images

public static void loadAbilities(String filePath)

.

loadAbilities("Abilities.csv");

How can I include the folder/files in the jar file or load them in any way?

Java Project

CodePudding user response:

try (BufferedReader br = new BufferedReader(
        new InputStreamReader(getClass().getResourceAsStream("/resources/foo.csv")))) {
    // Code here
}

Is the correct way to read a resource with a BufferedReader

  • Related