Configure Tomcat to use a different temp directory for file uploads

Solution 1:

The java.io.tmpdir in Tomcat is set to $CATALINA_BASE/temp. You can change it by setting the $CATALINA_TMPDIR environment variable before running startup.sh for Tomcat.

From catalina.sh:

#   CATALINA_TMPDIR (Optional) Directory path location of temporary directory
#                   the JVM should use (java.io.tmpdir).  Defaults to
#                   $CATALINA_BASE/temp.

Solution 2:

On windows if you are running Tomcat as a service you likely have a key similar to

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\myApplication\Parameters\Java

Set the string value options (double click to open) at the end of existing as:

-Djava.io.tmpdir=c:\{yourDir}

This worked for me.