0

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?

2 Answers 2

1

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");
Sign up to request clarification or add additional context in comments.

3 Comments

My file is in HADOOP_HOME is it still needed?
If your working directory is HADOOP_HOME and you are running within that, so its not needed
Are you sure it's the correct way to run this command because I don't see this working. It's also not throwing me an error or something.
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.