Skip to content
Advertisement

Executing helloworld.java in apache hadoop

can someone pls tell me how can i execute my HelloWorld.java in apache hadoop which contains

class Helloworld  
{  
  public static void main(String[] args)  
   {  
    Sytem.out.println("HelloWorld");  
    }  
 }

Am running a single node. Kindly tell me how can i run this piece of code or pls a send a link which is understandable for an absolute beginner.

Advertisement

Answer

The way a jar is run in hadoop is by the command

$HADOOP_HOME/bin/hadoop jar [your_jar_file]

You can also use -jar to force it to run as a local job. Useful for playing and debugging.

While I haven’t tested with such a simple application, I think it should print the line and then be done. Don’t hold me to that though. 😛

You might need to specify main throws Exception but I’m not 100% on that. My code has it.

I hope that helps. As mentioned in other answers, without getting into setting up Jobs and MapReduce, there’s not going to be a gain from Hadoop.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement