public static void run(String[] args, Properties properties) {
      if (args.length == 0) {
         System.err.println("You must specify a classname to launch");
      }
      // Scan the arguments looking for -s, --server-root=, -P, --properties=
      String root = null;
      String propertyFile = null;
      for (int i = 0; i < args.length; i++) {
         if ("-s".equals(args[i]) && i < args.length - 1) {
            root = args[i + 1];
            break;
         } else if (args[i].startsWith("--server-root=")) {
            root = args[i].substring(args[i].indexOf('=') + 1);
            break;
         } else if ("-P".equals(args[i]) && i < args.length - 1) {
            propertyFile = args[i + 1];
            break;
         } else if (args[i].startsWith("--properties=")) {
            propertyFile = args[i].substring(args[i].indexOf('=') + 1);
            break;
         }
      }
      if (propertyFile != null) {
         try (Reader r = Files.newBufferedReader(Paths.get(propertyFile))) {
            Properties loaded = new Properties();
            loaded.load(r);
            loaded.forEach(properties::putIfAbsent);
         } catch (IOException e) {
            throw new IllegalArgumentException(e);
         }
      }
      String home = properties.getProperty(INFINISPAN_SERVER_HOME_PATH, properties.getProperty("user.dir"));
      ClassLoader bootClassLoader = Loader.class.getClassLoader();
      ClassLoader serverClassLoader = classLoaderFromPath(Paths.get(home, "lib"), bootClassLoader);

      if (root == null) {
         root = properties.getProperty(INFINISPAN_SERVER_ROOT_PATH, Paths.get(home, DEFAULT_SERVER_ROOT_DIR).toString());
      }
      String lib = properties.getProperty(INFINISPAN_SERVER_LIB_PATH);
      if (lib != null) {
         for (String item : lib.split(File.pathSeparator)) {
            serverClassLoader = classLoaderFromPath(Paths.get(item), serverClassLoader);
         }
      } else {
         serverClassLoader = classLoaderFromPath(Paths.get(root, "lib"), serverClassLoader);
      }
      Thread.currentThread().setContextClassLoader(serverClassLoader);
      try {
         Class<?> mainClass = serverClassLoader.loadClass(args[0]);
         Method mainMethod = mainClass.getMethod("main", String[].class);
         String[] mainArgs = new String[args.length - 1];
         System.arraycopy(args, 1, mainArgs, 0, mainArgs.length);
         mainMethod.invoke(null, (Object) mainArgs);
      } catch (Exception e) {
         System.err.println(e.getMessage());
         e.printStackTrace(System.err);
      }
   }
@Test
   public void testLoaderViaPropertyFile() throws IOException {
      Properties properties = new Properties();
      properties.put(Loader.INFINISPAN_SERVER_LIB_PATH, String.join(File.pathSeparator, lib1.toString(), lib2.toString(), lib3.toString()));
      Path propertyFile = Paths.get(System.getProperty("build.directory"), "loader.properties");
      try (Writer w = Files.newBufferedWriter(propertyFile)) {
         properties.store(w, null);
      }
      properties = new Properties();
      properties.put("user.dir", System.getProperty("user.dir"));
      Loader.run(new String[]{LoaderTest.class.getName(), "-P", propertyFile.toAbsolutePath().toString()}, properties);
   }