Runtime.getRuntime().exec

Runtime.getRuntime().exec(String command, String[] envp, File dir)

What can I put for envp as a default value.  The reason I am using this overload is because I want put a command in the command line from a default position, (dir)
ARACK04Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
objectsConnect With a Mentor Commented:
Pass it null.
0
 
aozarovCommented:
what is default position (dir)? Do you mean current directory of the running process? if so, then new File(".") will do it.
Not sure what you mean by "using this overload"?
0
 
doronbConnect With a Mentor Commented:
If the envp should be empty, pass either null or "new String[0]".  If you need to pass any values in it, pass something like this:

  new String[] {"Value1", "Value2",..."ValueN"}
0
 
aozarovConnect With a Mentor Commented:
Just to make it clearer.
When you pass null to to the envp array the child process will inherit the environment variables from the Java process (the caller).
If you pass a string array (including empty) you will not inherit the parent environment process (though you can still get those valus
and pass them to the array as needed by using System.getEnv [only since Java 1.5]). Each string in the array should be in the format of "name=value".
Passing null or new File(".") or new File(System.getProperty("user.dir")) to the dir variable will cause the invoked process to run in the parent current directory.
0
All Courses

From novice to tech pro — start learning today.