使用Runtime.exec从JAVA运行hadoop jar命令 [英] Running hadoop jar command from JAVA using Runtime.exec
本文介绍了使用Runtime.exec从JAVA运行hadoop jar命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Runtime.exec从JAVA运行hadoop jar命令. 下面是示例代码:
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"});
但是我没有得到想要的输出.以下是我想从JAVA执行的hadoop命令:
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
我也没有任何例外.使用Runtime.getRuntime().exec的方式是否错误?
I am not getting any exception as well. Is the way Runtime.getRuntime().exec is used is wrong?
推荐答案
用以下命令替换您的命令:
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");
这篇关于使用Runtime.exec从JAVA运行hadoop jar命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文