0

How to run below hadoop command from java file :

hadoop jar '/home/ashish/Desktop/HADOOP_Basics/WordCount_Program/wordcount.jar' WordCount /WordCountTutorial/Input /WordCountTutorial/Output

Please explain in detail .

I am getting the below error while executing it through : Runtime rt = Runtime.getRuntime(); Process pr = rt.exec("hadoop jar '/home/ashish/Desktop/HADOOP_Basics/WordCount_Program/wordcount.jar' WordCount /WordCountTutorial/Input1 /WordCountTutorial/Output");

java.io.IOException: Cannot run program "hadoop": error=2, No such file or directory

Thanks in advance.

  • Possible duplicate of [Running Command Line in Java](https://stackoverflow.com/questions/8496494/running-command-line-in-java) – OneCricketeer Jul 17 '18 at 13:23
  • This question is diffrent with other one. Here i am asking for hadoop command not a normal java command. Please check @cricket_007 – Ashish Singh Parihar Mar 10 '19 at 17:23
  • I feel like you didn't read the other answers, and only the accecpted one. `rt.exec` is correct, **but**, you need `hadoop` available on your OS's path, which is externally managed from Java... You can fix it with `/full/path/to/hadoop jar ...` – OneCricketeer Mar 14 '19 at 23:40

1 Answers1

0

If you give full path to hadoop then it will run. eg command :

/home/project/usr/local/hadoop/bin/hadoop dfs -ls /
Nguyễn Văn Phong
  • 13,506
  • 17
  • 39
  • 56