void run()

in kyuubi-relocated-zookeeper-parent/kyuubi-relocated-zookeeper-34/src/main/java/org/apache/zookeeper/ZooKeeperMain.java [291:345]


  void run() throws KeeperException, IOException, InterruptedException {
    if (cl.getCommand() == null) {
      System.out.println("Welcome to ZooKeeper!");

      boolean jlinemissing = false;
      // only use jline if it's in the classpath
      try {
        Class<?> consoleC = Class.forName("jline.console.ConsoleReader");
        Class<?> completorC = Class.forName("org.apache.zookeeper.JLineZNodeCompleter");

        System.out.println("JLine support is enabled");

        Object console = consoleC.getConstructor().newInstance();

        Object completor = completorC.getConstructor(ZooKeeper.class).newInstance(zk);
        Method addCompletor =
            consoleC.getMethod("addCompleter", Class.forName("jline.console.completer.Completer"));
        addCompletor.invoke(console, completor);

        String line;
        Method readLine = consoleC.getMethod("readLine", String.class);
        while ((line = (String) readLine.invoke(console, getPrompt())) != null) {
          executeLine(line);
        }
      } catch (ClassNotFoundException e) {
        LOG.debug("Unable to start jline", e);
        jlinemissing = true;
      } catch (NoSuchMethodException e) {
        LOG.debug("Unable to start jline", e);
        jlinemissing = true;
      } catch (InvocationTargetException e) {
        LOG.debug("Unable to start jline", e);
        jlinemissing = true;
      } catch (IllegalAccessException e) {
        LOG.debug("Unable to start jline", e);
        jlinemissing = true;
      } catch (InstantiationException e) {
        LOG.debug("Unable to start jline", e);
        jlinemissing = true;
      }

      if (jlinemissing) {
        System.out.println("JLine support is disabled");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String line;
        while ((line = br.readLine()) != null) {
          executeLine(line);
        }
      }
    } else {
      // Command line args non-null.  Run what was passed.
      processCmd(cl);
    }
  }