动态查找java缓存目录
有什么方法可以以编程方式找到java缓存目录吗?
通常它位于这样的目录中:
System.getProperty("user.home") + someMiddleDir + "/Sun/Java/Deployment/cache/" +
versionCode;
在 Windows Vista 上解析为 "c:/Users/userId/AppData/LocalLow/Sun/Java/Deployment/cache/6.0"
但我需要找到它以某种更动态/精确的方式(最小硬编码代码/路径)。
Is there some way how to find the java cache directory programatically?
Normaly it is located in directory like this:
System.getProperty("user.home") + someMiddleDir + "/Sun/Java/Deployment/cache/" +
versionCode;
which resolves on Windows Vista into "c:/Users/userId/AppData/LocalLow/Sun/Java/Deployment/cache/6.0"
But I would need to find it in some more dynamic/precise way (minimum hardcoded code/path).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用这个:
com.sun.deploy.config.Config.getCacheDirectory()
一位好朋友告诉我这个令人讨厌的小方法:)
use this:
com.sun.deploy.config.Config.getCacheDirectory()
one good friend told me about this little nasty method :)
更通用的解决方案是读取系统属性deployment.user.cachedir。我用 Java 8 和 9 对此进行了测试,两者都适用于我的情况。
A more general solution is to read the system property
deployment.user.cachedir
. I tested this with Java 8 and 9, both work in my case.