• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

A library question

Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a class that would let me do things like close running programs, execute programs, and general windows stuff?
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For running programs - use Runtime.exec()
From the Java api specs:
public Process exec(String cmd, String[] envp) throws IOException
Executes the specified string command in a separate process with the specified environment.
This method breaks the command string into tokens and creates a new array cmdarray containing the tokens in the order that they were produced by the string tokenizer; it then performs the call exec(cmdarray, envp). The token parsing is done by a StringTokenizer created by the call:
new StringTokenizer(command)

with no further modification of the character categories.
The environment variable settings are specified by envp. If envp is null, the subprocess inherits the environment settings of the current process.
cmd - a specified system command.
envp - array of strings, each element of which has environment variable settings in format name=value.
a Process object for managing the subprocess.
SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess.
IOException - if an I/O error occurs

Here's an NT example (thanks to cs sakthi):

[This message has been edited by Tod Tryk (edited June 13, 2001).]
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!