控制 java.io.tmpdir 的环境变量? [英] Environment variable to control java.io.tmpdir?

查看:41
本文介绍了控制 java.io.tmpdir 的环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 TMP 环境变量来控制诸如 gcc 在何处写入临时文件之类的内容,但我似乎找不到 java 的 createTempFile API.

I've used the TMP environment variable to control things like where gcc writes it's temporary files, but I can't seem to find an equivalent for java's createTempFile API.

这样的环境变量存在吗?

Does such an environment variable exist?

推荐答案

嗯——由于这是由 JVM 处理的,所以我深入研究了 OpenJDK VM 源代码,认为 OpenJDK 所做的可能会模仿所做的由 Java 6 及更早版本提供.除了在 Windows 上,还有其他方法可以做到这一点并不令人放心.

Hmmm -- since this is handled by the JVM, I delved into the OpenJDK VM source code a little bit, thinking that maybe what's done by OpenJDK mimics what's done by Java 6 and prior. It isn't reassuring that there's a way to do this other than on Windows.

关于 Windows,OpenJDK 的 get_temp_directory() 函数对 GetTempPath() 进行 Win32 API 调用;这就是在 Windows 上,Java 反映 TMP 环境变量的值的方式.

On Windows, OpenJDK's get_temp_directory() function makes a Win32 API call to GetTempPath(); this is how on Windows, Java reflects the value of the TMP environment variable.

关于 LinuxSolaris,相同的 get_temp_directory() 函数返回 /tmp/ 的静态值.

On Linux and Solaris, the same get_temp_directory() functions return a static value of /tmp/.

我不知道实际的 JDK6 是否遵循这些确切的约定,但从每个列出的平台上的行为来看,它们似乎确实如此.

I don't know if the actual JDK6 follows these exact conventions, but by the behavior on each of the listed platforms, it seems like they do.

这篇关于控制 java.io.tmpdir 的环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆