Skip to content
Advertisement

In Java, how to insert multiple OS commands line?

I used the following code to execute simple OS command on Windows:

JavaScript

How to modify the code to insert multiple commands instead of one, so let us say I want to ping google.com, and then ping yahoo.com after that. I tried to create array string like:

JavaScript

However, this showed me an error.

I appreciate your help on this.

Advertisement

Answer

Use a loop:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement