Jump to content

Problem during executing Command Prompt through java


keshari
 Share

Recommended Posts

Hi AllMy current code is executing system commands through java programme,like “dir”,”date” itc.Whenever I run the code the desired output comes.But when I am running the code continuselly then lots of command prompt open regularlly.Is there any way to stop the code from execution untill unless the command prompt get closed manually?Here is my code.import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.IOException;interface IPerlService{ public String BZMCreateZone(String s); public int BZMRenew();}public class Sample { public void BZMCreateZone() { Runtime runtime; Process process; String s=null; String str=null; try { runtime = Runtime.getRuntime(); process =runtime.exec("cmd /c start dir"); str=process.toString(); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream())); s = reader.readLine(); } catch (IOException ex) { ex.printStackTrace(); } } public static void main(String[] args) { Sample obj_Sample= new Sample(); obj_Sample.BZMCreateZone(); }}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...