Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 26620

Summary: Environment variables not expanded in VM arguments
Product: [Eclipse Project] JDT Reporter: Jim Sculley <niceguy>
Component: DebugAssignee: JDT-Debug-Inbox <jdt-debug-inbox>
Status: VERIFIED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Jim Sculley CLA 2002-11-18 18:08:24 EST
When environment variables are included in the parameters passed to the VM by a
Launch Configuration, they are not expanded.  Here is a simple example:


Create the follwing class:

public class EnvBug {
    public static void main(String[] args) {
        System.out.println(System.getProperty("test.foo.bar"));
    }
}

Run the class from the command line and from within Eclipse with this VM parameter:

-Dtest.foo.bar=foobar

The code works as expected with the output:

foobar

Next create an environment variable FOO_BAR like this:

export FOO_BAR=foobar

Now run the code from a command line and from within Eclipse with this VM parameter:

-Dtest.foo.bar=$FOO_BAR

The command line code works as expected, but the output from Eclipse is:

$FOO_BAR

which clearly indicates that the environment variable is not being properly
expanded.

I have not tested this on platforms other than Linux, so I do not know if other
OSen are affected.
Comment 1 Darin Wright CLA 2002-11-25 10:53:12 EST
I believe this is OS specific. For example, on Win2000, using $Path from the 
command line evaluates to the same thing = "$Path".

Java does not provide access to environment variables (only system properties). 
It looks like the variable substitution you are getting on Linux is due to your 
OS support, not Java. 

I believe the "proper" way to pass around such values in Java is via system 
properties, or a properties file.

Do not intend to address for 2.1.
Comment 2 Darin Wright CLA 2004-06-15 15:00:54 EDT
In 3.0, we support "${env_var:FOO}" which resoves to the value of an 
environment variable.
Comment 3 Eclipse Webmaster CLA 2009-08-30 02:36:25 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.