Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6586237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:45:57+00:00 2026-05-25T16:45:57+00:00

System.getenv(name) needs the name of environment variable. I am trying to call Runtime.exec(String[], String[],

  • 0

System.getenv(name) needs the name of environment variable.

I am trying to call Runtime.exec(String[], String[], File), the secondary parameter need an array of environment variable, I am not sure whether subprocess will inherit environment variables from current process if I specified this parameter.

For example, if I pass new String[]{"NEWDIR=/home"} as secondary parameter and current java process has environment OLDDIR=/var, what is the return value of System.getenv("OLDDIR") in the subprocess?

updated:
Sorry, I have to use Java 1.4 and it seems that System.getenv() was introduced in 1.5?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:45:58+00:00Added an answer on May 25, 2026 at 4:45 pm

    System.getenv() will return a Map<String,String> with all of the environment variables.

    But you could just as easily switch to ProcessBuilder which is a more convenient API to start new processes.

    With ProcessBuilder you can simply call environment() and get a Map that contains existing environment variables and which you can manipulate how you want: i.e., if you add something to it, then that will be added to the new processes environment variables. If you remove something from it, it will not be present in the new process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

System.out.println(s.toString().substring(0,s.indexOf(.mp3))); i am downloading file from android application.. i need to name them as
[System.CodeDom.Compiler.GeneratedCodeAttribute(System.Runtime.Serialization, 3.0.0.0)] [System.Runtime.Serialization.DataContractAttribute(Name=TreeTraversalType, Namespace=http://schemas.datacontract.org/2004/07/DsLib)] public enum TreeTraversalType : int { [System.Runtime.Serialization.EnumMemberAttribute()] PreOrder = 0,
What's the difference between system properties System.getProperties() and environment variables System.getenv() in a JVM?
System.IO.Directory.GetFiles() returns a string[] . What is the default sort order for the returned
System.Environment.OSVersion does not appear to indicate which Edition of Windows 2003 is installed (Standard,
I'm trying to set a variable that should be accessible from outside PHP. Ideally
System.out.print(My string: ); My string: BUILD SUCCESSFUL (total time: 1 second) System.out.print(My string );
System Specs: Infopath 2007 with c# code-behind Webservices Active Directory I need to get
Hi as the subject reads System.getenv(HOME) in my action class (struts2) and deploy that
Python's access to environment variables does not accurately reflect the operating system's view of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.