Breaking News
Home / Java / Java Snippets / How to execute Shell Command?

How to execute Shell Command?

Execute Shell Command JavaThis snippets demonstrates how to execute shell command (native to OS) and captures its output as if it was running from the command line. Once the command is executed, it waits for it, and captures any output produced by the command and dumps it to the screen.

Remember this piece of code has to be executed from a Unix/Linux shell, or cygwin or dos shell in order for this to work.

 

 [pb_builder]

Check Also

How to progamatically get the Java version?

Snippet The key here is to use the system property java.version and get minor and …

Advertisment ad adsense adlogger