Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

HBase - creating table using Java API - Not Compiling

avatar
Expert Contributor

Hi - i've written code to add table to HBase (HDP 2.4), the code is not compiling...

Import Statements :

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.hbase.HBaseConfiguration;

import org.apache.hadoop.hbase.HColumnDescriptor;

import org.apache.hadoop.hbase.HTableDescriptor;

import org.apache.hadoop.hbase.client.HBaseAdmin;

import org.apache.hadoop.hbase.util.Bytes;

Command :

javac hbase/labfiles/Exercise3/HBase_SchemaTester.java

Error is as shown below ->

[root@sandbox ~]# javac hbase/labfiles/Exercise3/HBase_SchemaTester.java hbase/labfiles/Exercise3/HBase_SchemaTester.java:6: error: package org.apache.hadoop.hbase does not exist import org.apache.hadoop.hbase.HBaseConfiguration; ^ hbase/labfiles/Exercise3/HBase_SchemaTester.java:7: error: package org.apache.hadoop.hbase does not exist import org.apache.hadoop.hbase.HColumnDescriptor; ^ hbase/labfiles/Exercise3/HBase_SchemaTester.java:8: error: package org.apache.hadoop.hbase does not exist import org.apache.hadoop.hbase.HTableDescriptor; ^ hbase/labfiles/Exercise3/HBase_SchemaTester.java:9: error: package org.apache.hadoop.hbase.client does not exist import org.apache.hadoop.hbase.client.HBaseAdmin; ^ hbase/labfiles/Exercise3/HBase_SchemaTester.java:10: error: package org.apache.hadoop.hbase.util does not exist import org.apache.hadoop.hbase.util.Bytes;

-----------------------------

Which Additional jars do i need to add to Classpath ?

I've already added following Hbase & Hadoop specific jars to my classpath.

/usr/hdp/current/hbase-regionserver/lib/*.jar

/usr/hdp/current/hbase-master/lib*.jar

/usr/hdp/2.4.0.0-169/hbase/lib/*.jar

/usr/hdp/2.4.0.0-169/hadoop/lib/*.jar

/usr/hdp/current/hbase-client/lib/*.jar

My Classpath currently looks like this ->

---------------------------

[root@sandbox ~]# echo $CLASSPATH /usr/hdp/current/hbase-regionserver/lib/*.jar:/usr/hdp/current/hbase-master/lib*.jar:/usr/hdp/2.4.0.0-169/hbase/lib/*.jar:/usr/hdp/2.4.0.0-169/hadoop/lib/*.jar:/usr/hdp/current/hbase-client/lib/*.jar:/usr/hdp/2.4.0.0-169/hadoop/conf:/usr/hdp/2.4.0.0-169/hadoop/lib/*:/usr/hdp/2.4.0.0-169/hadoop/.//*:/usr/hdp/2.4.0.0-169/hadoop-hdfs/./:/usr/hdp/2.4.0.0-169/hadoop-hdfs/lib/*:/usr/hdp/2.4.0.0-169/hadoop-hdfs/.//*:/usr/hdp/2.4.0.0-169/hadoop-yarn/lib/*:/usr/hdp/2.4.0.0-169/hadoop-yarn/.//*:/usr/hdp/2.4.0.0-169/hadoop-mapreduce/lib/*:/usr/hdp/2.4.0.0-169/hadoop-mapreduce/.//*::mysql-connector-java-5.1.17.jar:mysql-connector-java-5.1.31-bin.jar:mysql-connector-java.jar:/usr/hdp/2.4.0.0-169/tez/*:/usr/hdp/2.4.0.0-169/tez/lib/*:/usr/hdp/2.4.0.0-169/tez/conf

1 ACCEPTED SOLUTION

avatar
Super Collaborator

@Karan Alang Here is the documentation from javac classpath:

Classpath entries that are neither directories nor archives (.zip or .jar files) nor * are ignored.

So, you should use just a simple '*' instead of '*.jar'. I believe hbase-client/lib/* would be enough. You also may use --verbose to track what javac is doing.

View solution in original post

1 REPLY 1

avatar
Super Collaborator

@Karan Alang Here is the documentation from javac classpath:

Classpath entries that are neither directories nor archives (.zip or .jar files) nor * are ignored.

So, you should use just a simple '*' instead of '*.jar'. I believe hbase-client/lib/* would be enough. You also may use --verbose to track what javac is doing.