If this file is supposed to be part of your app the way class files are (so, effectively read-only, an asset that you pack in with the rest. Think texture maps for games, or icons for user interfaces), use getResourceAsStream
, as the resource in question may not even be a file (java projects tend to ship as jars, and an entry in a jar is not a file!).
If not, well, then figure out a way to get the full path info into your code, because it's not going to magically figure out that you have a dir structure with "App" and "files", which is non-standard. (the standard route is src/main/java/pkgname/Type.java
for java files, and src/main/resources/pkgname/open.png
for assets that just need to be there (don't need compiling).
If you set up a project in your favourite IDE according to this structure and configured using e.g. maven or gradle, then getResourceAsStream
works during dev time, and also at runtime, even if the resource is inside the jar.