How to use this method of java?
exec
public Process exec(String command,
String[] envp,
File dir)
throws IOException
Does somebody know how to use it?
Web Development
exec
public Process exec(String command,
String[] envp,
File dir)
throws IOException
Does somebody know how to use it?
by okujava
hi!
with this method u can start a native process of your system: word, excell ...
the first parameter is the Strin name of the application (word.exe, write, command.com...)
the second parameter is an array of arguements for your system process, if required (or null for none), the third parameter is the working directory for your new process (should exist!)
so, if u run this:
public class Test{
public static void main(String args[]) throws Exception{
Runtime r = Runtime.getRuntime();
Process p = r.exec("write test.txt", null, new java.io.File("c:\\"));
}
}
it should open (on windows) c:\test.txt in wordpad
ciao
shota
by jason
by srishankar.r
Hi,
The exec method of the Process class is used to create a child process. The first parameter is the command and second one is the environment and third one is the file path.
Here for example.
if command is something like "notepad" a new notepad application will be opened.
if command is something like "winword" a new word document will be opened.
Regards,
Srishankar
by jason
by jason
This discussion is closed to new replies.
Sort by Trending