java.io.tmpdir
Java System Property allows you to read or set a temporary directory for use by the java runtime.The default value will differ based upon the operating system that java is running on.
java.io.tmpdir
ExplainedThe java.io.tmpdir 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: java.io.tmpdir directory does not exist
Here are some other File Path related Java system properties:
Java has supported the java.io.tmpdir
system property since at least Java 1.4, support may go back even further.
java.io.tmpdir
on StartupYou can set the java.io.tmpdir
java system property during startup of the java runtime using the -D
command line argument:
java -Djava.io.tmpdir=c:\temp MyAppMain
You may also be able to specify java.io.tmpdir
via the JAVA_TOOL_OPTIONS
environment variable:
JAVA_TOOL_OPTIONS=-Djava.io.tmpdir=c:\temp
java.io.tmpdir
at RuntimeYou can set java.io.tmpdir at runtime with the following Java code:
System.setProperty("java.io.tmpdir", "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 java.io.tmpdir system property may be cached within an internal private static variable of the implementing class.
To read the value of java.io.tmpdir at runtime, you can use this Java code:
String propertyValue = System.getProperty("java.io.tmpdir"); if (propertyValue != null) { System.out.println("java.io.tmpdir = " + propertyValue); } else { System.out.println("java.io.tmpdir was null"); }