FileNotFoundException when running a jar file

I got this path .\\src\\aee\\user\\scorePercentage.csv . It's running when I execute this in Netbeans. But when I created a jar file, the scorePercentage.csv can't be found.

Upvotes: 2

Views: 900

Answers (2)

Praneeth Peiris
Praneeth Peiris

Reputation: 2088

And working directory for a .jar file is /src directory. you can represent resources by getClass().getResources(String);
Ex:getClass().getResources("/aee/user/scorePercentage.csv");

Upvotes: -1

Zenexer
Zenexer

Reputation: 19611

You should either export it to the directory from which the application is running, or use Class.getResource and embed it in the jar. If you use the src directory anywhere in your code, you are doing something wrong.

Upvotes: 2

Related Questions