# Class ZooKeeperMain

java.lang.Object
org.apache.zookeeper.ZooKeeperMain

@Public public class ZooKeeperMain extends Object
The command line client to ZooKeeper.

## Field Summary

Fields
Modifier and Type
Field
Description
`protected org.apache.zookeeper.ZooKeeperMain.MyCommandOptions`
`cl`
`protected int`
`commandCount`
`protected int`
`exitCode`
`protected HashMap<Integer,String>`
`history`
`protected String`
`host`
`protected boolean`
`printWatches`
`protected ZooKeeper`
`zk`

## Constructor Summary

Constructors
Constructor
Description
`ZooKeeperMain(String[] args)`
`ZooKeeperMain(ZooKeeper zk)`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`addToHistory(int i, String cmd)`
Makes a list of possible completions, either for commands or for zk nodes if the token to complete begins with /
`protected void`
`connectToZK(String newHost)`
`void`
`executeLine(String line)`
`static List<String>`
`getCommands()`
`boolean`
`getPrintWatches()`
`protected String`
`getPrompt()`
`static void`
`main(String[] args)`
`static void`
`printMessage(String msg)`
`protected boolean`
`processCmd(org.apache.zookeeper.ZooKeeperMain.MyCommandOptions co)`
`protected boolean`
`processZKCmd(org.apache.zookeeper.ZooKeeperMain.MyCommandOptions co)`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### cl

protected org.apache.zookeeper.ZooKeeperMain.MyCommandOptions cl

### history

protected HashMap<Integer,String> history

### commandCount

protected int commandCount

### printWatches

protected boolean printWatches

### exitCode

protected int exitCode

### zk

protected ZooKeeper zk

### host

protected String host

## Constructor Details

### ZooKeeperMain

public ZooKeeperMain(String[] args) throws IOException, InterruptedException

Throws:
  `IOException`
  `InterruptedException`

### ZooKeeperMain

public ZooKeeperMain(ZooKeeper zk)

## Method Details

### getPrintWatches

public boolean getPrintWatches()

### addToHistory

protected void addToHistory(int i, String cmd)
Makes a list of possible completions, either for commands or for zk nodes if the token to complete begins with /

### getCommands

public static List<String> getCommands()

### getPrompt

protected String getPrompt()

### printMessage

public static void printMessage(String msg)

### connectToZK

protected void connectToZK(String newHost) throws InterruptedException, IOException

Throws:
  `InterruptedException`
  `IOException`

### main

public static void main(String[] args) throws IOException, InterruptedException

Throws:
  `IOException`
  `InterruptedException`

### executeLine

public void executeLine(String line) throws InterruptedException, IOException

Throws:
  `InterruptedException`
  `IOException`

### processCmd

protected boolean processCmd(org.apache.zookeeper.ZooKeeperMain.MyCommandOptions co) throws IOException, InterruptedException

Throws:
  `IOException`
  `InterruptedException`

### processZKCmd

protected boolean processZKCmd(org.apache.zookeeper.ZooKeeperMain.MyCommandOptions co) throws CliException, IOException, InterruptedException

Throws:
  `CliException`
  `IOException`
  `InterruptedException`