amod
amod

Reputation: 4272

Running hadoop jar command from JAVA using Runtime.exec

I am trying to run an hadoop jar command from JAVA using Runtime.exec. Below is the sample code:

Runtime.getRuntime().exec(new String[]{"bin/hadoop", "jar /home/hadoop/jar/test.jar /user/hduser/myinput/input /user/hduser/newoutput"});

However I am not getting the desired output. Below is my hadoop command which I want to execute from JAVA:

bin/hadoop jar /home/hadoop/jar/test.jar /user/hduser/myinput/input /user/hduser/newoutput

I am not getting any exception as well. Is the way Runtime.getRuntime().exec is used is wrong?

Upvotes: 0

Views: 521

Answers (2)

Ishan Kumar
Ishan Kumar

Reputation: 2082

Give the class name where you defined the driver code.

bin/hadoop jar /home/hadoop/jar/test.jar Package_name.className /user/hduser/myinput/input /user/hduser/newoutput

Upvotes: 1

Nishu Tayal
Nishu Tayal

Reputation: 20880

Replace your command with following command:

Runtime.getRuntime().exec("HADOOP_HOME/bin/hadoop jar /home/hadoop/jar/test.jar /user/hduser/myinput/input /user/hduser/newoutput");

Upvotes: 1

Related Questions