title: read data from HBase by using Spark with JAVA
body: <p>I want to access HBase via Spark using JAVA. I have not found any examples for this besides <a href="https://stackoverflow.com/questions/25040709/how-to-read-from-hbase-using-spark">this</a> one. In the answer is written, </p>
  
  <blockquote>
    <p>You can also write this in Java</p>
  </blockquote>
  
  <p>I copied this code from <a href="https://stackoverflow.com/questions/25040709/how-to-read-from-hbase-using-spark">How to read from hbase using spark</a> :</p>
  
  <pre><code>import org.apache.hadoop.hbase.client.{HBaseAdmin, Result}
  import org.apache.hadoop.hbase.{ HBaseConfiguration, HTableDescriptor }
  import org.apache.hadoop.hbase.mapreduce.TableInputFormat
  import org.apache.hadoop.hbase.io.ImmutableBytesWritable
  
  import org.apache.spark._
  
  object HBaseRead {
    def main(args: Array[String]) {
      val sparkConf = new SparkConf().setAppName("HBaseRead").setMaster("local[2]")
      val sc = new SparkContext(sparkConf)
      val conf = HBaseConfiguration.create()
      val tableName = "table1"
  
      System.setProperty("user.name", "hdfs")
      System.setProperty("HADOOP_USER_NAME", "hdfs")
      conf.set("hbase.master", "localhost:60000")
      conf.setInt("timeout", 120000)
      conf.set("hbase.zookeeper.quorum", "localhost")
      conf.set("zookeeper.znode.parent", "/hbase-unsecure")
      conf.set(TableInputFormat.INPUT_TABLE, tableName)
  
      val admin = new HBaseAdmin(conf)
      if (!admin.isTableAvailable(tableName)) {
        val tableDesc = new HTableDescriptor(tableName)
        admin.createTable(tableDesc)
      }
  
      val hBaseRDD = sc.newAPIHadoopRDD(conf, classOf[TableInputFormat], classOf[ImmutableBytesWritable], classOf[Result])
      println("Number of Records found : " + hBaseRDD.count())
      sc.stop()
    }
  }
  </code></pre>
  
  <p>Can anyone give me some hints how to find the correct dependencies, objects and stuff? </p>
  
  <p>It seems like <code>HBaseConfiguration</code> is in <code>hbase-client</code>, but I actually stuck on <code>TableInputFormat.INPUT_TABLE</code>. Shouldn´t this be in the same dependency?</p>
  
  <p>Is there a better way to access hbase with spark?</p>