Java – get “program files” path

How can I get the current computer’s “Program Files” path with Java?

Get path to Program Files

Inside my NSIS installer, how do I always get the path to the users Program Files, not the C:/Program Files (x86)/ but always just C:/Program Files/ The following variable $PROGRAMFILES gives C:/Progr

How to get the path of running java program [duplicate]

This question already has an answer here: Find where java class is loaded from 7 answers Is there a way to get the path of main class of the running java program. structure is D:/ |—Project |

How to get Program Files folder path (not Program Files (x86)) from 32bit WOW process?

I need to get the path to the native (rather than the WOW) program files directory from a 32bit WOW process. When I pass CSIDL_PROGRAM_FILES (or CSIDL_PROGRAM_FILESX86) into SHGetSpecialFolderPath it

Java – Get string path of resource files

I want to access to get the string path to my resource key files. If I debug the project in eclipse, everything works like a charm but if I export the project to a runnable .jar file – the project can

C++ Get Program files dir, append extra path and execute

I’m trying to write a few simple lines of code that will get the ‘Program Files’ dir path on both XP and Vista/7 (on vista/7 I need the path to the x86 folder), add some extra path to an application a

Java path to Program Files folder in windows 64bit

i`m trying to get the default Program Files folder on java. When I use: System.getenv(ProgramFiles) It returns C:/Program Files instead of C:/Program Files (x86) I can add manually +(x86) but

How To Get System Folder Path(C:/Windows C:/Program Files) in Windows using C++?

I am programming in c++ MFC, I want to get C:/windows c:/program files folder path. Sometimes user may setup windows in other folder such as c:/windows0. Is there any API to get absolute pat

Get path of “Program files” folder that contains 32-bit programs

How do I determine the full path of the folder that contains 32-bit programs using VBA? It’s called Program Files on 32-bit Windows systems, but on 64-bit systems it’s called Program Files (x86).

Program to get all files within a directory in Java

I’m working on this program to get all the files in the directory. For some reason I am getting a NullPointerException on Line 16. I don’t know why though since this is a template that seemed to work

Access to the path is denied when uploading file to program files/some commercial program

I get an error : Access to the path ‘C:/Program Files (x86)/MetaTrader FIX/experts/indicators/Awesome.ex4’ is denied./n at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System


Simply by calling System.getenv(…)


Notice it will only work in Windows environments, of course 🙂

Use the System.getenv() method:

public class EnvironmentVariableExample {

    public static void main(String[] args) {

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

System.getenv("%programfiles%" +" " +"(x86)"); for the 32-bit folder on 64-bit PC's.

Also, it works on any language in Windows Vista and newer. Calling either of the posted responses will work on any language installation, in fact.