Path (Class<?> klass) { final URL classFileURL = klass.getResource(klass.getSimpleName() + ".class"); if (classFileURL == null) { throw new IllegalStateException("Could not get .class file location from class " + klass.getName()); } return URLUtil.urlToFile(classFileURL).toPath().toAbsolutePath(); }