not able to change java.io.tmpdir

18,533

Solution 1

You need to use that command as part of running a program, not just java -Dkey=value.

java -Djava.io.tmpdir=/temporary com.foo.Bar

where com.foo.Bar is the class which contains the main method.

Alternatively, you can do this programmatically.

System.setProperty("java.io.tmpdir", "/temporary");

Solution 2

Take a look at this answer 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.

Share:
18,533
mujeeb
Author by

mujeeb

Updated on June 26, 2022

Comments

  • mujeeb
    mujeeb almost 2 years

    I am trying to change the java.io.tmpdir directory using this command

    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.

    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

  • Talha Asghar
    Talha Asghar over 2 years
    This System.setProperty("java.io.tmpdir", "/temporary"); is the best way i think.