Jump to content
  • Advertisement
Sign in to follow this  
jake_Ghost

[java] Running an exe in Java

This topic is 4885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
shell cmd ?

see java documentation of Runtime.exec(String cmd[,String []envp])

in this example cmd is bat file name so I just pushing my commands to bat and then execute alls in one instead of this type of collection object You can pass to this function single DOS or WINSHELL or script.

void runmyshell(String cmd)
{
String s = null;
try
{
Process p=Runtime.getRuntime().exec(cmd);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output from the command
while ((s = stdInput.readLine()) != null)System.out.println(s);
// read any errors from the attempted command
while ((s = stdError.readLine()) != null)System.out.println(s);
}
}catch(IOException e)
{
System.out.println(e);
}
}
}




[Edited by - HellCreator on June 1, 2005 9:55:47 AM]

Share this post


Link to post
Share on other sites
You can try looking at this too:

http://www-ppg.dcs.st-and.ac.uk/Java/DynamicCompilation/


It invokes the Java compiler from the command line, and test for shell, and uses some of the system properties. It's good looking code for the most part (except for the >80 char per line thing). So basically easy to understand.

L-

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!