I am facing issue with run simple Hbase example.
I have create on HbaseTest.java which create one table and insert some records. In Unix, I can able to compile the java class. by.
$javac -classpath hbase-0.94.2.jar:hadoop-core-1.0.4.jar HBaseTest.java
But I am not able to run this program by :
$java -classpath hbase-0.94.2.jar:hadoop-core-1.0.4.jar HBaseTest
Above command is not working for me. Not sure what is the issue ? Is it correct way to run Hbase Java Example ?
You can use “hbase classpath” to get the class path needed.
/* * Compile and run with: * javac -cp `hbase classpath` TestHBase.java * java -cp `hbase classpath` TestHBase */ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.client.*; import org.apache.hadoop.hbase.util.*; public class TestHBase { public static void main(String[] args) throws Exception { Configuration conf = HBaseConfiguration.create(); HBaseAdmin admin = new HBaseAdmin(conf); try { HTable table = new HTable(conf, "test-table"); Put put = new Put(Bytes.toBytes("test-key")); put.add(Bytes.toBytes("cf"), Bytes.toBytes("q"), Bytes.toBytes("value")); table.put(put); } finally { admin.close(); } } }