package io.gitlab.jfronny.inceptum.launchwrapper; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.nio.file.*; import java.util.stream.Stream; public class Main { public static void main(String[] args) throws ClassNotFoundException, IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { if (args.length == 0) throw new IllegalArgumentException("Missing class argument"); String forceloadNatives = System.getProperty("inceptum.forceloadNatives"); if (forceloadNatives != null) { Path p = Paths.get(forceloadNatives); if (Files.exists(p)) { try (Stream paths = Files.list(p)) { paths.forEach(Main::load); } } else { throw new IllegalArgumentException("Could not find forceloadNatives path"); } } Class mainClass = Class.forName(args[0]); String[] newArgs = new String[args.length - 1]; System.arraycopy(args, 1, newArgs, 0, args.length - 1); mainClass.getMethod("main", String[].class).invoke(null, new Object[] {newArgs}); } private static void load(Path path) { System.load(path.toAbsolutePath().normalize().toString()); } }