?
Solved

Runtime.getRuntime().exec

Posted on 2005-04-01
4
Medium Priority
?
267 Views
Last Modified: 2013-11-18
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)
0
Comment
Question by:ARACK04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Expert Comment

by:aozarov
ID: 13685899
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
 
LVL 92

Accepted Solution

by:
objects earned 600 total points
ID: 13686131
Pass it null.
0
 
LVL 9

Assisted Solution

by:doronb
doronb earned 200 total points
ID: 13686285
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
 
LVL 15

Assisted Solution

by:aozarov
aozarov earned 200 total points
ID: 13686367
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

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to dynamically set the form action using jQuery.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question