Running Jar Program
Running Jar Program
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
4. Right click the project and select run as configurations and click new launch configuration
under java application. Give a name of the configuration and select the project name and
class of the project. Press on apply button and then close button to close the window.
5. Right click on the project and click on export. Select runnable jar file under java. Select
launch configuration file and destination directory (ex: dest/wordcount.jar) to store the jar
file.
6. Make sure that $jps command will list all the running daemons as follows.
Node manager
Name node
Data node
Secondary Name node
Resource manager
8. Copy the input directory having input files into hdfs as follows:
10. To see the results, display the contents of the output directory. It has two files _success and
part-r-00000.
11. The results can be displayed by using the following command:
Assuming that:
/user/dbda/wordcount/input/file01
/user/dbda/wordcount/input/file02
Output:
Bye 1
Goodbye 1
Hadoop 2
Hello 2
World 2