Java System Properties
Quick Reference Guide Java System Property

The Java System Property allows you to read or set a temporary directory for use by the java runtime.

Default Value

c:\temp\ /tmp/

The default value will differ based upon the operating system that java is running on. Explained

The system property defines the file system path of a temporary directory for use by the java runtime.

As of Java 20, a warning message will be displayed if the temporary directory does not exist upon startup of the JVM:

WARNING: directory does not exist

Related System Properties

Here are some other File Path related Java system properties:

Supported Since

Java has supported the system property since at least Java 1.4, support may go back even further.

Setting on Startup

You can set the java system property during startup of the java runtime using the -D command line argument:

java\temp MyAppMain

You may also be able to specify via the JAVA_TOOL_OPTIONS environment variable:\temp

Setting / Reading at Runtime

You can set at runtime with the following Java code:

System.setProperty("", "c:\temp");

WARNING: Depending on the property and JVM version using setProperty may or may not work if the JDK Java class that uses this variable has already been loaded. The value of the system property may be cached within an internal private static variable of the implementing class.

To read the value of at runtime, you can use this Java code:

String propertyValue = System.getProperty("");
if (propertyValue != null) {
    System.out.println(" = " + propertyValue);
} else {
    System.out.println(" was null");