Got it.  It is because i should use the full path of java cmd( on my site it is 
/usr/java/default/bin/java). 
If just us java, it is actually point to /usr/bin/java. 

Thanks,
Lei




[email protected]

From: Ted Yu
Date: 2014-01-16 13:32
To: [email protected]
Subject: Re: org.apache.hadoop.hbase.KeyValue not found in 
gnu.gcj.runtime.SystemClassLoader
Which version of HBase are you using ?

Can you tell us how you launched your program ?

Cheers


On Wed, Jan 15, 2014 at 6:48 PM, [email protected] <[email protected]> wrote:

>
> Hi,
>
> I write a simple java class to query the rowkey of a hase table.  It
> compile successfully but meet errors when running it.
>
> Exception in thread "main" java.lang.NoClassDefFoundError: HBaseT
>    at java.lang.Class.initializeClass(libgcj.so.10)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.hadoop.hbase.KeyValue not found in
> gnu.gcj.runtime.SystemClassLoader{urls=[file:./],
> parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
>    at java.net.URLClassLoader.findClass(libgcj.so.10)
>    at java.lang.ClassLoader.loadClass(libgcj.so.10)
>    at java.lang.ClassLoader.loadClass(libgcj.so.10)
>    at java.lang.Class.initializeClass(libgcj.so.10)
>
> Following is my java code:
>
> public class HBaseT {
>     public static Configuration configuration;
>     static {
>         configuration = HBaseConfiguration.create();
>     }
>     public static void main(String[] args) {
>         queryByRowKey("userdigest", "-10000007542109572047");
>     }
>     public static void queryByRowKey(String tableName, String keyName){
>         HTablePool pool = new HTablePool(configuration, 1000);
>         HTableInterface table = (HTableInterface) pool.getTable(tableName);
>         try{
>                 Get get = new Get(Bytes.toBytes(keyName));
>                 get.addFamily(Bytes.toBytes("cf"));
>                 Result r = table.get(get);
>                 System.out.println(r.getRow());
>                 for(KeyValue kv:r.raw()){
>                 System.out.print(new String(kv.getKey()));
>
>                 System.out.println(new String(kv.getValue()));
>             }
>
>         }catch(IOException e){
>                 e.printStackTrace();
>         }
>     }
> }
>
> Any insights on this?
>
> Thanks,
> Lei
>
>
>
> [email protected]

Reply via email to