Im just trying to interact with Hbase using Java
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.util.*;
import org.apache.hadoop.hbase.HBaseConfiguration;
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();
}
}
}
Above is my program and My TestHBase folder contains the following items
hbase-0.94.6.1.3.0.0-0380.jar
TestHBase.class
And i have created jar using the following code
java>jar -cvf TestHBase.jar -C TestHBase/ .
And i have run my jar using the following code
Hadoop> Hadoop jar C:\java\bin\TestHBase.jar com.bgt.TestHBase
But im getting the following error
C:\HDP>hadoop jar C:\java\jdk1.6.0_31\bin\zip.jar com.bgt.TestHBase
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hba
se/HBaseConfiguration
at com.bgt.TestHBase.main(TestHBase.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.util.RunJar.main(RunJar.java:160)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.HBaseConfig
uration
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 6 more
Can anyone help me
Thanks