I’ve done all the work that hadoop requires, but there seems something wrong with it, for example:
I have a class Hello.class, when I use the command “java Hello” it works correctly, but when I try to use the command “hadoop Hello” it reports that “cannot load or find the main class”, but when I use “jar” command to change Hello.class into Hello.jar, however, I use the command “hadoop jar Hello.jar Hello”, this time it works correctly just as I used the command “java Hello”
What is wrong with my configuration?
In file etc/profile the following has been added:
export JAVA_HOME=/usr/jdk1.7.0_04
export HADOOP_INSTALL=/usr/hadoop-1.0.1
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_INSTALL/bin
export CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
I’ve added “export JAVA_HOME=/usr/jdk1.7.0_04” into file “hadoop-env.sh”
I’ve changed core-site.xml, hdfs-site.xml, mapred-site.xml accordingly
Is there anyone having the same problem?
The
hadoop Hellocommand runs hadoop and looks for a class named Hello on the current classpath – which doesn’t contain your class.Bundling your class into a jar and running
hadoop jar myjar.jar Hellotells hadoop to add the jar file myjar.jar to the classpath and then run the class named Hello (which is now on the classpath)If you want to add a class to the classpath configure the
HADOOP_CLASSPATHenvironment variable