I'm trying to compile and run my simple test HBase code in java using terminal Ubuntu 14.04, I've install Hadoop and HBase correctlly and are running. The code is :
/*
* 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();
}
}
}
I've got the long string 'hbase classpath' and the command
javac -cp 'hbase classpath' TestHBase.java
run correctly giving TestHBase.class file, but when I run the command
java -cp 'hbase classpath' TestHBase
it gives this error :
Error: Could not find or load main class
How could I solve this ?