Compiled the program. At the very root of the classpath is a file.

I work in IDEA and finds the file, but I don’t want to compile it.

The file path is: file:\D:\Program.jar!\file.json

And he writes that he cannot find him.

I get the file through: getClass().getClassLoader().getResource()

What could be the problem?

  • try direct slash. - Roman C

1 answer 1

 URL resource = getClass() .getClassLoader() .getResource("/file.json"); 
  • but am I not doing that? URL turns out to be null - Tsyklop
  • If null is returned, then there is no file in the root of the jar file. Check out IDEA is packing it. - Sergey Gornostaev
  • checked. opened the jar file - he was there - Tsyklop
  • @Tsyklop try without the first slash, just "file.json" - Alex Chermenin
  • @AlexChermenin and so and so tried. - Tsyklop