title: How create Kafka ZKStringSerializer in Java?
body: <p>In searching for how to create a Kafka topic through the API, I found this example in Scala:</p>
  
  <pre><code>import kafka.admin.AdminUtils
  import kafka.utils.ZKStringSerializer
  import org.I0Itec.zkclient.ZkClient
  
  // Create a ZooKeeper client
  val sessionTimeoutMs = 10000
  val connectionTimeoutMs = 10000
  val zkClient = new ZkClient("zookeeper1:2181", sessionTimeoutMs,
                              connectionTimeoutMs, ZKStringSerializer)
  
  // Create a topic with 8 partitions and a replication factor of 3
  val topicName = "myTopic"
  val numPartitions = 8
  val replicationFactor = 3
  val topicConfig = new Properties
  AdminUtils.createTopic(zkClient, topicName, 
                         numPartitions, replicationFactor, topicConfig)
  </code></pre>
  
  <p>Source: <a href="https://stackoverflow.com/a/23360100/871012">https://stackoverflow.com/a/23360100/871012</a></p>
  
  <p>The last arg <code>ZKStringSerializer</code> is apparently a Scala object.  It is not clear to me how to make this example work in Java.</p>
  
  <p>This post <a href="https://stackoverflow.com/questions/21327960/how-to-create-a-scala-object-in-clojure">How to create a scala object in clojure</a> asks the same question in Clojure and the answer was:</p>
  
  <pre><code>ZKStringSerializer$/MODULE$
  </code></pre>
  
  <p>which in Java would (I think) translate to:</p>
  
  <pre><code>ZKStringSerializer$.MODULE$
  </code></pre>
  
  <p>But when I try that (or any number of other variations) none of them compile.<br>
  The compilation error is:</p>
  
  <pre><code>KafkaTopicCreator.java:[16,18] cannot find symbol
  symbol:   variable ZKStringSerializer$
  location: class org.sample.KafkaTopicCreator
  </code></pre>
  
  <p>I am using kafka_2.9.2-0.8.1.1 and Java 8.</p>