-1

I made a javafx project, when I finished I made a executable jar file. When I run it I get this error:

java.io.FileNotFoundException: src\Radiatorlista.txt

This is how my code looks like:

File radiatorok = new File("src/Radiatorlista.txt");

I know that this path will not work. I don't know how to specify the correct relative path. This is how my jar file looks like.

Progman
  • 16,827
  • 6
  • 33
  • 48

1 Answers1

0

The answer is that you need to put your txt files (or whatever you wan't to open) in the folder where your jar file is. For example my jar file is here:

F:/Example/for/my/file

You need to put your files in the file folder. Then change your code like this:

File file = new File("Mytxt.txt");

After this your program should work.