我试着用终端ubuntu14.04在java中编译和运行我的简单测试hbase代码,我已经正确安装了hadoop和hbase并且正在运行。代码是:
/*
* 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();
}
}
}
我得到了长字符串“hbase classpath”和命令
javac -cp 'hbase classpath' TestHBase.java
正确运行testhbase.class文件,但是当我运行命令时
java -cp 'hbase classpath' TestHBase
它给出了以下错误:
Error: Could not find or load main class
我怎样才能解决这个问题?
这是我的终端截图12
暂无答案!
目前还没有任何答案,快来回答吧!