0

I compiled my jar and got the following:

    java.io.FileNotFoundException: Employees\firstname lastname.txt (The system cannot find the path specified)
    Exception in thread "main" java.lang.NullPointerException
    at EmployeeList.createEmployees(EmployeeList.java:127)
    at EmployeesWindow.<init>(EmployeesWindow.java:64)
    at ScheduleBuilder.<init>(ScheduleBuilder.java:17)
    at Start.main(Start.java:7)

My file path looks like this:

    File file = new File("Employees\\" + tempfirst + " " + templast + ".txt");

The folder is located here and contains a bunch employees text files:

    F:\Programming\Schedule Builder\Employees

How can I fix this so that I do not get this error?

Gizmo
  • 1
  • 4
  • change `Employees` to `F:\\Programming\\Schedule Builder\\Employees` – Scary Wombat Feb 14 '18 at 08:41
  • verify that the path of the file in your code is indeed the path you assume it is – Stultuske Feb 14 '18 at 08:41
  • Scary Wombat's suggestion would work, but I would recommend to put the path (if you want to hardcode it) in a properties file, that way you won't have to recompile each time you decide to change the path – Stultuske Feb 14 '18 at 08:42
  • what is tempfirst and templast – John Joe Feb 14 '18 at 08:44
  • Yes, I agree that mine was not a good solution, just a solution – Scary Wombat Feb 14 '18 at 08:44
  • 2
    Possible duplicate of [Reading a resource file from within jar](https://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar) – Mad Physicist Feb 14 '18 at 08:45
  • If you do not want to recompile or to store the path to that file in some sort of configuration, simply make sure your current directory is `F:\Programming\Schedule Builder\` (or whichever other location that contains the Employee directory) before you run your program. – david a. Feb 14 '18 at 08:47

0 Answers0