private void loadUserDefinedCommands() {
    String[] userCommandPackages = getUserCommandPackages().toArray(new String[] {});

    if (userCommandPackages.length == 0) {
      return;
    }

    // Load commands found in all of the packages
    try (ClasspathScanLoadHelper scanner = new ClasspathScanLoadHelper(userCommandPackages)) {
      Set<Class<?>> foundClasses =
          scanner.scanPackagesForClassesImplementing(CommandMarker.class, userCommandPackages);
      for (Class<?> klass : foundClasses) {
        try {
          add((CommandMarker) klass.newInstance());
        } catch (Exception e) {
          logWrapper.warning("Could not load User Commands from: " + klass + " due to "
              + e.getLocalizedMessage()); // continue
        }
      }
      raiseExceptionIfEmpty(foundClasses, "User Command");
    } catch (IllegalStateException e) {
      logWrapper.warning(e.getMessage(), e);
      throw e;
    }
  }
this is used when getting the instance in a cache server. We are getting the
user-command-package from distribution properties. used by OnlineCommandProcessor.
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/CommandManager.java