• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A library question

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
Parameters:
cmd - a specified system command.
envp - array of strings, each element of which has environment variable settings in format name=value.
Returns:
a Process object for managing the subprocess.
Throws:
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).]
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic