1

I'm trying to run a jar file with hadoop using command

hadoop jar test.jar org.ipiran.hadoop.sample.TestMapReduce /user/data.txt /output/1.txt 4

But it returns error

Exit code: 1 Exception message: System cannot find the path specified

I tried without specifying the class but got the same result. I have file data.txt. My main java code

public int run(String[] args) throws Exception {
    Configuration conf = this.getConf();
    conf.set("fs.defaultFS", "hdfs://localhost:9000/");
    conf.set("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class.getName());
    conf.set("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class.getName());
    conf.set("source", args[2]);
    long numUpdated = 1;
    int code = 0;
    int numIterations = 1;
    FileSystem hdfs = FileSystem.get(conf);
    while (numUpdated > 0) {
        logger.info("Iteration: " + numIterations);
        String input, output;
        Job job = Job.getInstance(conf, "word count");
        if (numIterations == 1) {
            input = args[0];
        } else {
            input = args[1] + "-" + (numIterations - 1);
        }
        output = args[1];// + "-" + numIterations;

        job.setJarByClass(TestMapReduce.class);
        job.setMapperClass(testmap.class);
        job.setReducerClass(TestReduce.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);
        FileInputFormat.addInputPath(job, new Path(input));
        FileOutputFormat.setOutputPath(job, new Path(output));
        code = job.waitForCompletion(true) ? 0 : 1;

        Counters jobCounters = job.getCounters();
        numUpdated = jobCounters.
            findCounter(MoreIterations.numUpdated).getValue();
        if (numIterations > 1) {
            hdfs.delete(new Path(input), true);
            logger.info("Updated: " + numUpdated);
        }
        numIterations += 1;
    }
    return code;
}

I'm using windows 10. Does anybody know what is wrong here?

3
  • See this stackoverflow.com/questions/11553042/… Commented Jan 21, 2018 at 13:49
  • I don't know how to apply it with hadoop code. Can you elaborate? Commented Jan 21, 2018 at 14:00
  • Why are you uploading files to /user rather than your actual HDFS user folder like /user/nnnzzzaaa? Commented Jan 21, 2018 at 15:35

1 Answer 1

1

You are using Windows 10, however you are treating it is if you are using Linux.

In Linux "/someDir/someFile means that there is a file under a directory that is under the root directory.

You have to change the paths of your data files to some location that is compitable with windows.

By the way, do you have hadoop installed on your machine ?

I would recommend using a linux VM, you can use Cloudera VM as it has everything installed

https://www.cloudera.com/downloads/quickstart_vms/5-12.html

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your response. I do have hadoop installed hadoop on my machine. The files are located on hdfs, and it uses file system like on linux. I use the same path that I used when copied those files to hdfs. If I'm wrong, then should the path look like? I can't use cloudera because I'm using laptop and it doesn't have enough ram.
@nnnzzzaa There is no /user folder on your local filesystem, so the paths cannot be exactly the same
@nnnzzzaaa If the file is expected to be in HDFS then you need to use the hdfs path that is pointing to your file. Normally the folder on HDFS Is /usr/something not /user Please Confirm the path by using hadoop fs -cat /user/data.tx
Path is correct. I just typed in your command and it printed my file.
I guess you could need to try hdfs://yourpath to distinguish it from normal local file system

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.