Ashish Pancholi Ashish Pancholi - 1 year ago 168
Java Question

When does System.getProperty("") return "c:\temp"

Just curious as to when

. According to the Java Docs-

The default temporary-file directory is specified by the system property On UNIX systems the default value of this property is typically "/tmp" or "/var/tmp"; on Microsoft Windows systems it is typically "c:\temp". A different value may be given to this system property when the Java virtual machine is invoked, but programmatic changes to this property are not guaranteed to have any effect upon the the temporary directory used by this method.

But in my case-


Always returns-

C:\Users\admin\AppData\Local\Temp\ i.e. %TEMP%

In what conditions will it return

EDITED: If I change %TEMP% to C:\Temp then I will get C:\Temp, right? But the documentation shows c:\Temp instead of C:\Temp.

Answer Source

In MS Windows the temporary directory is set by the environment variable TEMP. In XP, the temporary directory was set per-user as Local Settings\Temp.

If you change your TEMP environment variable to C:\temp, then you get the same when you run :


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download