Linux 无法更改 java.io.tmpdir
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10108262/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
not able to change java.io.tmpdir
提问by mujeeb
I am trying to change the java.io.tmpdir directory using this command
我正在尝试使用此命令更改 java.io.tmpdir 目录
java -Djava.io.tmpdir=/temporary
But this doesnot succeed and displays the 'Usage' of the java command. I am doing this in a RHEL machine.
但这不会成功并显示 java 命令的“用法”。我在 RHEL 机器上这样做。
Thanks in advance
提前致谢
I have deployed an application on WebLogiv which uses axis2 version 1.5. I find that axis2 1.5 using java.io.tmpdir to store its temp files. I want the location where these temp files are stored. Where in the weblogic do I specify the java.io.tmpdir value
我在 WebLogiv 上部署了一个使用axis2 1.5 版的应用程序。我发现axis2 1.5 使用java.io.tmpdir 来存储它的临时文件。我想要存储这些临时文件的位置。我在 weblogic 中的何处指定 java.io.tmpdir 值
回答by adarshr
You need to use that command as part of running a program, not just java -Dkey=value
.
您需要将该命令用作运行程序的一部分,而不仅仅是java -Dkey=value
.
java -Djava.io.tmpdir=/temporary com.foo.Bar
where com.foo.Bar
is the class which contains the main
method.
com.foo.Bar
包含main
方法的类在哪里。
Alternatively, you can do this programmatically.
或者,您可以以编程方式执行此操作。
System.setProperty("java.io.tmpdir", "/temporary");
回答by Jon7
Take a look at this answer https://stackoverflow.com/a/1924159/594793
看看这个答案https://stackoverflow.com/a/1924159/594793
Specifically, this part:
具体来说,这部分:
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 the temporary directory used by this method.
调用 Java 虚拟机时,可能会为此系统属性指定不同的值,但不能保证对此属性的编程更改对此方法使用的临时目录有任何影响。