Return-Path: X-Original-To: apmail-hbase-user-archive@www.apache.org Delivered-To: apmail-hbase-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 46CB262A3 for ; Tue, 24 May 2011 11:02:55 +0000 (UTC) Received: (qmail 16590 invoked by uid 500); 24 May 2011 11:02:53 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 16556 invoked by uid 500); 24 May 2011 11:02:53 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Received: (qmail 16548 invoked by uid 99); 24 May 2011 11:02:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 May 2011 11:02:53 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of praveenesh@gmail.com designates 209.85.214.41 as permitted sender) Received: from [209.85.214.41] (HELO mail-bw0-f41.google.com) (209.85.214.41) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 May 2011 11:02:46 +0000 Received: by bwz17 with SMTP id 17so8185337bwz.14 for ; Tue, 24 May 2011 04:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=0bnkC+nypD/9IG9WGQORgSO/lnfoYy+w04V+iNiv8L8=; b=LvXBglpDccaMcSPq5Pt4HaKz333XlJ/barDAv6UgswTIwaS7T4I+hkX5gRBdjCILGL tuJj+PDe7r09ntk5J2DQ/Z5N1gQZxvzoPkhvgqddug/TPUG5w4Py1k9B0vnOpcIqQxyT Mzl7LkYM3ctFnDiUz4vzV8C+jIvNg0Jb22YhY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=H+ZaYqW1T4ft5oEojsE04eJ6Gbql/g9uiyp5Y48XsjsxdhbsdZBw2EFKaWlmiGYTEC i2C78waumBZr2Trwg4GrRqp+u6oPCRT9u8nZKJZPqykjTzH1Hv/IV6U6JSm3hm7c5mN7 Py69beyNdaHQkK17Apm+nJUFftK5zKx+DX3Ng= MIME-Version: 1.0 Received: by 10.204.128.90 with SMTP id j26mr799414bks.116.1306234595223; Tue, 24 May 2011 03:56:35 -0700 (PDT) Received: by 10.204.153.208 with HTTP; Tue, 24 May 2011 03:56:35 -0700 (PDT) In-Reply-To: References: <557E5EDB02B4C8459878EF1EC723AD281E2CCB75@mail1.impetus.co.in> Date: Tue, 24 May 2011 16:26:35 +0530 Message-ID: Subject: Re: How to compile simple Hbase code ? From: praveenesh kumar To: user@hbase.apache.org Content-Type: multipart/alternative; boundary=0015174c41c80aaa2f04a403710b X-Virus-Checked: Checked by ClamAV on apache.org --0015174c41c80aaa2f04a403710b Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Okie what i did is added the folder containing my .class file in the classpath, along with commons-logging-1.0.4.jar and log4j-1.2.15.jar in my classpath: so now Myclasspath variable looks like : MYCLASSPATH=3D"/usr/local/hadoop/hadoop/hadoop-0.20.2-core.jar:/usr/local/h= adoop/hbase/hbase/hbase-0.20.6.jar:/usr/local/hadoop/hbase/hbase/lib/zookee= per-3.2..2.jar::/usr/local/hadoop/hbase/hbase/lib/commons-logging-1.0.4.jar= :/usr/local/hadoop/hbase/hbase/lib/log4j-1.2.15.jar:/usr/local/hadoop/hbase= /" and then I used java -classpath $MYCLASSPATH ExampleClient.java now its running.. Thanks.!!! On Tue, May 24, 2011 at 3:52 PM, praveenesh kumar wro= te: > which class is not in classpath ??? > I already put hadoop-core.jar , hbase-core.jar and zookeeper.jar in my > classpaths... > What else I need to put in my classpath ??? > > On Tue, May 24, 2011 at 3:48 PM, Vivek Mishra < > vivek.mishra@impetus.co.in> wrote: > >> It means Class is not in your classpath. >> >> -----Original Message----- >> From: praveenesh kumar [mailto:praveenesh@gmail.com] >> Sent: Tuesday, May 24, 2011 3:31 PM >> To: user@hbase.apache.org >> Subject: How to compile simple Hbase code ? >> >> I am simply using HBase API, not doing any Map-reduce work on it. >> Following is the code I have written , simply creating the file on HBase= : >> >> import java.io.IOException; >> import org.apache.hadoop.hbase.HBaseConfiguration; >> import org.apache.hadoop.hbase.HColumnDescriptor; >> import org.apache.hadoop.hbase.HTableDescriptor; >> import org.apache.hadoop.hbase.client.Get; >> import org.apache.hadoop.hbase.client.HBaseAdmin; >> import org.apache.hadoop.hbase.client.HTable; >> import org.apache.hadoop.hbase.client.Put; >> import org.apache.hadoop.hbase.client.Result; >> import org.apache.hadoop.hbase.client.ResultScanner; >> import org.apache.hadoop.hbase.client.Scan; >> import org.apache.hadoop.hbase.util.Bytes; >> public class ExampleClient { >> public static void main(String args []) throws IOException { >> HBaseConfiguration config =3D new HBaseConfiguration(); >> >> HBaseAdmin admin =3D new HBaseAdmin(config); >> HTableDescriptor htd =3D new HTableDescriptor("test"); >> HColumnDescriptor hcd =3D new HColumnDescriptor("data"); >> htd.addFamily(hcd); >> admin.createTable(htd); >> >> byte [] tablename =3D htd.getName(); >> HTableDescriptor [] tables =3D admin.listTables(); >> >> if(tables.length !=3D1 && Bytes.equals(tablename, tables[0].getName())) >> { >> throw new IOException("Failed to create table"); >> } >> >> HTable table =3D new HTable(config,tablename); >> byte[] row1 =3D Bytes.toBytes("row1"); >> Put p1 =3D new Put(row1); >> byte[] databytes =3D Bytes.toBytes("data"); >> p1.add(databytes,Bytes.toBytes("1"),Bytes.toBytes("value1")); >> table.put(p1); >> >> Get g =3D new Get(row1); >> Result result =3D table.get(g); >> System.out.println("Get : "+ result); >> Scan scan =3D new Scan(); >> ResultScanner scanner =3D table.getScanner(scan); >> try >> { >> for(Result scannerResult: scanner) >> { >> System.out.println("Scan : " + scannerResult); >> } >> }catch(Exception e ){ >> e.printStackTrace(); >> } >> finally{ >> scanner.close(); >> } >> table.close(); >> } >> } >> >> Now I have set the classpath variable in /etc/environment as >> >> * >> >> MYCLASSPATH=3D"/usr/local/hadoop/hadoop/hadoop-0.20.2-core.jar:/usr/loca= l/hadoop/hbase/hbase/hbase-0.20.6.jar:/usr/local/hadoop/hbase/hbase/lib/zoo= keeper-3.2.2.jar >> * >> now I am compiling my code with javac command >> >> *$javac -classpath $MYCLASSPATH ExampleClient.java >> * >> It is working fine. >> While running, I am using java command >> *$java -classpath $MYCLASSPATH ExampleClient*, >> >> then I am getting the following error : >> *Exception in thread "main" java.lang.NoClassDefFoundError: ExampleClien= t >> Caused by: java.lang.ClassNotFoundException: ExampleClient* >> >> * at java.net.URLClassLoader$1.run(URLClassLoader.java:217) >> at java.security.AccessController.doPrivileged(Native Method) >> at java.net.URLClassLoader.findClass(URLClassLoader.java:205) >> at java.lang.ClassLoader.loadClass(ClassLoader.java:321) >> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) >> at java.lang.ClassLoader.loadClass(ClassLoader.java:266)* >> >> Could not find the main class: ExampleClient. Program will exit. >> >> But I am running the code from the same location. and ExampleClient.clas= s >> file exists at that location. >> >> ________________________________ >> >> Write to us for a Free Gold Pass to the Cloud Computing Expo, NYC to >> attend a live session by Head of Impetus Labs on =91Secrets of Building = a >> Cloud Vendor Agnostic PetaByte Scale Real-time Secure Web Application on= the >> Cloud =91. >> >> Looking to leverage the Cloud for your Big Data Strategy ? Attend Impetu= s >> webinar on May 27 by registering at >> http://www.impetus.com/webinar?eventid=3D42 . >> >> >> NOTE: This message may contain information that is confidential, >> proprietary, privileged or otherwise protected by law. The message is >> intended solely for the named addressee. If received in error, please >> destroy and notify the sender. Any use of this email is prohibited when >> received in error. Impetus does not represent, warrant and/or guarantee, >> that the integrity of this communication has been maintained nor that th= e >> communication is free of errors, virus, interception or interference. >> > > --0015174c41c80aaa2f04a403710b--