How to set java.io.tmpdir
using Quarkus in native mode in a container.
I've tried different options but didn't manage to have the Files. createTempDirectory
use my own value:
TMPDIR as env
-> not workingENTRYPOINT ./application -Dquarkus.http.host=0.0.0.0 -Djava.io.tmpdir=${TMPDIR:-/tmp}
-> works where it is not static
I should probably set TempFileHelper.tmpdir
as runtime init?
How to set java.io.tmpdir
using Quarkus in native mode in a container.
I've tried different options but didn't manage to have the Files. createTempDirectory
use my own value:
TMPDIR as env
-> not workingENTRYPOINT ./application -Dquarkus.http.host=0.0.0.0 -Djava.io.tmpdir=${TMPDIR:-/tmp}
-> works where it is not static
I should probably set TempFileHelper.tmpdir
as runtime init?
- what package is TempFileHelper.tmpdir from ? – Max Rydahl Andersen Commented Mar 13 at 8:53
2 Answers
Reset to default 3There's a bug open in graalvm about this issue: https://github/oracle/graal/issues/7731
The person who reported the bug mentioned just last week (on Mar 6 2025) that it was fixed in Java version: 25+11-LTS, vendor version: Oracle GraalVM 25-dev+11.1
.
You'll need to downgrade or upgrade the version of graalvm you are using to avoid this bug.
According to the Java documentation
If the
directory
argument isnull
then the system-dependent default temporary-file directory will be used. The default temporary-file directory is specified by the system propertyjava.io.tmpdir
. On UNIX systems the default value of this property is typically"/tmp"
or"/var/tmp"
; on Microsoft Windows systems it is typically"C:\\WINNT\\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 temporary directory used by this method.
There is no indication that setting the environment variable TMPDIR
should work, and in fact it doesn't work in JVM mode either.
As noted by @Augusto there is an upstream GraalVM issue for the described issue.
The cause of the issue is that in earlier GraalVM versions the java.io.tmpdir
is explicitly set to `/tmp/` in linux, see https://github/oracle/graal/blob/64ee7141016377bfe2b2ba6ffbb87536ae009d59/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java#L44-L51
The issue seems to be fixed in GraalVM for JDK 25 by https://github/oracle/graal/commit/03bc71dd4c236d2b7f29892c9106c90ca75d31a1#diff-e6462ab7fcea98cf6d96cc67964ce7db6055aebcd5a00554234426fc0019e4cdR284 in https://github/oracle/graal/pull/10613
I should probably set
TempFileHelper.tmpdir
as runtime init?
The right way to fix this would be to substitute jdk.internal.util.StaticProperty#javaIoTmpDir
which is however already being substituted by GraalVM itself, so IMO this can only be fixed on the GraalVM side. If you feel like the fix should be backpoted to GraalVM for JDK 21 please create an issue (and if you feel like, open a backport PR) on https://github/graalvm/graalvm-community-jdk21u/issues