
Observations and results
It's now time to execute your program in the Hadoop environment. If you are using Eclipse or any other IDE to write your code, you can just export your solution as a JAR file. If you are using a text editor to write your code, you need to compile it and make a JAR file from the compiled class files. Put all three classes in the same folder and execute the following command to compile them:
$ javac -classpath $(hadoop classpath) UtilityBillSummary.java UtilityMapper.java UtilityReducer.java
Once that has been complied successfully, execute the following command to make a JAR file that contains the compiled .class files:
$ jar -cvf utilitysummary.jar *.class
Now it's time to pass your JAR file to Hadoop for execution with the following command:
hadoop<space>jar<space>{yourfilename.jar}<space>{MainClassName}<space>{inputfilename.txt}<space>{outputDirectory}
In our case, the values will be as follows:

Type in the following command as per the values mentioned previously to execute your first MapReduce Job:
$ hadoop jar utilitysummary.jar UtilitySummary /utility/log.txt /utilityOutput
The following figure shows a few lines from the output generated in the terminal. This output contains the successful completion message:

Now when you browse the output directory /utilityoutput, you should see the two following files:
- _SUCCESS, which tells you that the job was completed successfully
- part-r-00000, which contains the actual result gathered; there may be multiple files here, with a sequence, such as 00001, 00002, and so on
The following figure displays the files generated in the output directory:

To view the result of your program, display the contents of the part-r-00000 file as shown in the following screenshot. As you can see, it displays the total amount paid for each utility:
