Hadoop query regarding setJarByClass method of Job class

Tag: hadoop Author: xzw1223 Date: 2010-09-26

In the Hadoop API documentation it's given

that

setJarByClass 

public void setJarByClass(Class<?> cls)

Set the Jar by finding where a given class came from.

What exactly does this explanation mean? does it creates a JAR file from the class file argument specified in the method above? and does that jar file is executed for the MapReduce task.?

Best Answer

This method sets the jar file in which each node will look for the Mapper and Reducer classes.

It does not create a jar from the given class. Rather, it identifies the jar containing the given class. And yes, that jar file is "executed" (really the Mapper and Reducer in that jar file are executed) for the MapReduce job.

(Also see Stanley Xu's answer to a similar question about the need for this method since you give the jar on the command line)

Other Answer1

job.setJarByClass(WordCount.class);

Helps to identify the Jar which contains the Mapper and Reducer by specifying a class in that Jar.