0

the directory of the image

I'm practicing for my project by trying to replicate the PvZ game. Why the getResourceAsStream() keep returning null.

I have tried "/PvZ/data/gfx/mainMenu.png" and "PvZ/data/gfx/mainMenu.png", but none of them worked.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • For `getResourceAsStream()` to work, the location has to be on the class path, and it is not. If you want to open them as files on the file system, use `Files.newInputStream(Path, OpenOption...)`. Otherwise, you need to ensure that the resource location is properly put on the classpath. – Mark Rotteveel Nov 09 '22 at 08:23

0 Answers0