Thursday, 21 June 2012

Creating the jar file to execute in hadoop.

If you are like me, that you have not really been exposed at using java programs directly from the console, you will find it a bit difficult at the beginning.

Luckily IDEs like Eclipe and Netbeans generate executable jars for us and that is pretty much what we need to execute our programs.

In eclipse you have to explicitly generate the jar file of your project, and for this you can have a look at some tutorials on the internet.

Under Netbeans (as it is my case) everytime you execute or build your project, a new jar file is generated under the "dist" subfolder of your project.

I recommend you copy this folder to wherever you want so you can include it in the hadoop jar execution command. I.e something like this:

In the context of the wordcounter example:

bin/hadoop jar dist/WordCount.jar /collections/gutenberg outputfolder

Where:
- "bin/hadoop" is the "hadoop" program located in my "bin" subfolder
- jar tells the hadoop program, that we want to run a jar file/program
- "dist/WordCount.jar" is our wordcount program, located under the "dist" subfolder
- "/collections/gutenberg"   the input file located in the DFS (i.e. hosted in the cluster storage)

- "outputfolder"  The folder where the output is gonna be written to.

Hope this helps

Cheers,

Jesus

1 comment: