Access a resource outside a jar from the jar
问题 I'm trying to access a resource from a jar file. The resource is located in the same directory where is the jar. my-dir: tester.jar test.jpg I tried different things including the following, but every time the input stream is null: [1] String path = new File(".").getAbsolutePath(); InputStream inputStream = this.getClass().getResourceAsStream(path.replace("\\.", "\\") + "test.jpg"); [2] File f = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath());