Hi You are seeing these compilation errors because some hadoop jars are absent in your classpath.
You need to add the required jars from HADOOP_HOME and HADOOP_HOME/lib in your class path. Easier approach would be to build and pack your application jar in an IDE like eclipse , deploy the jar on your hadoop client machine and run it using 'hadoop jar ...' command. Regards Bejoy KS Sent from handheld, please excuse typos. -----Original Message----- From: R J <[email protected]> Date: Wed, 14 Nov 2012 15:21:39 To: Robert Evans<[email protected]>; [email protected]<[email protected]> Reply-To: [email protected] Subject: Re: Hadoop Java compilation error Thanks a lot. I studied and tried the WordCount.java program as in the URL http://hadoop.apache.org/docs/r0.20.2/mapred_tutorial.html $ javac -version javac 1.6.0 $javac -classpath /usr/local/hadoop-1.0.4/hadoop-core-1.0.4.jar:/usr/local/hadoop-1.0.4/lib/commons-cli-1.2.jar -d wordcount_classes WordCount.java I get 48 compilation errors. The first few are like: WordCount.java:6: package org.apache.hadoop.fs does not exist import org.apache.hadoop.fs.Path; WordCount.java:7: package org.apache.hadoop.conf does not exist import org.apache.hadoop.conf.*; It seems the javac compiler cannot locate the hadoop packages. Is there any other way to include the packages in the compilation command? Thank you. ________________________________ From: Robert Evans <[email protected]> To: "[email protected]" <[email protected]>; R J <[email protected]> Sent: Wednesday, November 14, 2012 3:36 PM Subject: Re: Hadoop Java compilation error Hadoop is not a java runtime environment it runs special map/reduce applications. Go search for "how to write a hadoop program" and there will be lots of examples or you can pick up a book on Hadoop and that can help you with some examples too. --Bobby From: R J <[email protected]> Reply-To: "[email protected]" <[email protected]>, R J <[email protected]> Date: Wednesday, November 14, 2012 3:00 PM To: "[email protected]" <[email protected]> Subject: Hadoop Java compilation error Hi All, I installed Hadoop 1.0.4 on Cygwin and tried to run Java HelloWorld but I get exception error: $ bin/hadoop javac HelloWorld.java java.lang.NoClassDefFoundError: javac Exception in thread "main" $ echo $JAVA_HOME /cygdrive/c/java $ javac HelloWorld.java $ java HelloWorld Hello, World I have set JAVA_HOME environment variable in hadoop-env.sh . How do I make it work on hadoop? Thank you.
