java.nio.file.Path for a classpath resource This one works for me: return Path.of(ClassLoader.getSystemResource(resourceName).toURI());