hadoop 中 运行 程序出错?

Error in running program in hadoop?

我在 wordcount 的 hadoop 2.7 中的程序在 运行 的终端上给出错误,即使它在 eclipse 中没有显示任何错误。

hadoop jar WordCount.jar WordCount user/amandeep/file.txt wordcountoutput

显示的错误如下:-

Exception in thread "main" java.lang.ClassNotFoundException: WordCount
    at java.net.URLClassLoader.run(URLClassLoader.java:366)
    at java.net.URLClassLoader.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:274)
at org.apache.hadoop.util.RunJar.run(RunJar.java:214)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)

我的 Wordcount 程序是 -

package hadoop_first;

import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileOutputFormat;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;

public class WordCount extends Configured implements Tool{

    @Override
    public int run(String[] args) throws Exception {
        if(args.length<2){
            System.out.println("Give directory properly");
            return -1;
        }
        JobConf conf = new JobConf(WordCount.class);
        conf.setJarByClass(WordCount.class);
        FileInputFormat.setInputPaths(conf,new Path(args[0]));
        FileOutputFormat.setOutputPath(conf,new Path(args[1]));
        conf.setMapperClass(WordCountMapper.class);
        conf.setReducerClass(WordReducer.class);
        conf.setMapOutputKeyClass(Text.class);
        conf.setMapOutputValueClass(IntWritable.class);

        conf.setOutputKeyClass(Text.class);
        conf.setOutputValueClass(IntWritable.class);

        JobClient.runJob(conf);
        return 0;
    }
    public static void main(String args[]){
        try{
            int exitCode=ToolRunner.run(new WordCount(),args);
            System.exit(exitCode);
        }
        catch(Exception e){
            System.out.println("Error");
        }
    }
} 

通过在终端输入的命令中添加包名称解决了问题

hadoop jar WordCount.jar hadoop_first.WordCount file.txt wordcountoutput