开发者

How to execute a command(with arguments) in ubuntu 10.04 environment

开发者 https://www.devze.com 2023-01-25 18:36 出处:网络
I\'ve a created an standalone application in which my aim is to execute a command(with arguments Eg: gedit filename). How to do this through java pr开发者_开发问答ogramming. I tried the following piec

I've a created an standalone application in which my aim is to execute a command(with arguments Eg: gedit filename). How to do this through java pr开发者_开发问答ogramming. I tried the following piece of code, but its not working.

String[] command = new String[]{"gedit", "abc"};  
Process child = Runtime.getRuntime().exec(command);  

I've tried all sorts of combinations on the exec() command and also used JavaProcessBuilder many times but I seem to get no solution for this. Can anyone please help me with this. Please try to give the code, I've already visited many links but all in vain. Please help.

-Thanks in advance


You need to provide the full qualified path to gedit (e.g /home/user/bin/gedit)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号