2

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.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • ..and your question is? BTW - use the tip I describe [here](http://stackoverflow.com/q/16116469/418556) to discover where the 'current directory' is. Likely it points to a different directory than you expect. – Andrew Thompson Apr 20 '13 at 06:47
  • Check your jar. Is the file present. How did you create the jar. If you are doing it using netbeans, check your settings if it includes only *.class files. Check whether the path to load the file is correct. – AllTooSir Apr 20 '13 at 06:50
  • *.class files are included,even the .csv – John Seigfred Manzanares Apr 20 '13 at 07:05
  • 1) Add @NoobUnChained (or whoever) to notify them of a new comment. 2) A resource in a Jar cannot be accessed by `File`, instead it must be accessed by `URL`. 3) Is this CSV for read only? – Andrew Thompson Apr 20 '13 at 07:10
  • @Andrew - that csv file is for reading and writing – John Seigfred Manzanares Apr 22 '13 at 07:03

2 Answers2

2

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.

Zenexer
  • 18,788
  • 9
  • 71
  • 77
-1

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");

Praneeth Peiris
  • 2,008
  • 20
  • 40