java64-bitprogram-files

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 if the user will use 32bit system it will be the wrong folder.


Solution

  • You should be using

    System.getenv("ProgramFiles(X86)")
    

    You can find the full reference on Wikipedia.