[FIXED] How to execute command with parameters?


How am I to execute a command in Java with parameters?

I’ve tried

Process p = Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php -m 2"});

which doesn’t work.

String[] options = new String[]{"option1", "option2"};
Runtime.getRuntime().exec("command", options);

This doesn’t work as well, because the m parameter is not specified.


See if this works (sorry can’t test it right now)

Runtime.getRuntime().exec(new String[]{"php","/var/www/script.php", "-m", "2"});

Answered By – Chris Stratton

Answer Checked By – Clifford M. (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published