Alex Rivera | Logout

Java - get "program files" path

Asked 2011-01-31T13:27:07.253
27

How can I get the current computer's "Program Files" path with Java?

Edit
Report

1 Answer

2

Use the System.getenv() method:

public class EnvironmentVariableExample {

    public static void main(String[] args) {
        System.out.println(System.getenv("ProgramFiles"));
        System.out.println(System.getenv("MadeUpEnvVar"));
    }
}

If the variable doesn't exist, it will simply return null.

answered 2011-01-31T13:40:09.683

Your Answer