void (String[] args) { int exitStatus; try { ClassLoader original = Thread.currentThread().getContextClassLoader(); List<Path> files = new ArrayList<>(); for (String path : System.getProperty("java.class.path").split(File.pathSeparator)) { if (!path.isEmpty()) { files.add(Path.of(path)); } } UrlClassLoader loader = UrlClassLoader.build().files(files).parent(original.getParent()) .useCache() .usePersistentClasspathIndexForLocalClassDirectories() .get(); Thread.currentThread().setContextClassLoader(loader); exitStatus = (Integer)loader.loadClass(CucumberMain.class.getName()) .getMethod("run", String[].class, ClassLoader.class) .invoke(null, args, loader); } catch (InvocationTargetException e) { LOG.warn(e); var targetException = e.getTargetException(); if (targetException instanceof AssertionError) { exitStatus = 0; } else { exitStatus = 1; } } catch (Throwable e) { LOG.warn(e); exitStatus = 1; } System.exit(exitStatus); }