enter image description here Create a project in the Eclipse IDE, create a class and file in the same place. Described as:

URL urlFnumZ = HelixAtlaskirov.class.getResource("FnumZ.txt"); 

If I run it in Eclipse, it works with a bang, and after building the jar, when I wrap it in exe using the launch4j program, I get an error:

Caused by: java.io.FileNotFoundException: file: \ C: \ G \ Helix-Lab.exe! \ \ Atlaskirov \ helix \ jfx \ FnumZ.txt (Syntax error in the file name, folder name, or volume label)

I also tried to describe how:

 URL urlFnumZ = HelixAtlaskirov.class.getClassLoader().getResource("FnumZ.txt"); то же самое. 
  • one
    The resource path must be specified relative to the location of the class file. In your case, is it so? - Alexander Chernin
  • And look at the jar file. Check that the file is there and is in the place from where you are trying to download it. - Sergey Gornostaev
  • Yes, relative to the class, and it is there from where I am trying to load it into a jar file - atlaskirov

2 answers 2

I decided by changing the file reading method to: InputStream urlFnumZ = HelixAtlaskirov.class.getResourceAsStream ("FnumZ.txt"); Scanner fsNz = new Scanner (urlFnumZ);

    If the file is located immediately under the resources, then you need to add a slash:

     URL urlFnumZ = HelixAtlaskirov.class.getResource("/FnumZ.txt"); 
    • so he immediately throws an error to me inside the IDE: - atlaskirov
    • And why do you need the path to the file? To count it? If yes, then it is better to use InoutStream, I can write the correct version for the jar file. - Andrii Torzhkov