public static File getFile(String name) { URL url = Thread.currentThread().getContextClassLoader().getResource(name.replace(File.separatorChar, '/')); if(url != null) { try { return new File(url.toURI()); } catch (Exception var3) { throw new RuntimeException("Resource was found on classpath, but cannot be resolved to a normal file (maybe it is part of a JAR file): " + name); } } else { File file = new File(name); if(file.exists()) { return file; } else { throw new RuntimeException("Cannot find resource in classpath or in file-system (relative to CWD): " + name); } } }