Thursday, April 05, 2007

Java does not honour TMPDIR

My colleague encountered a wierd behaviour in deploying his SunONE application server in Solaris. He realised that when the / partition is near full, he will have problem in starting the daemon.

I understand that most utilities in UNIX honour the TMPDIR environment variable to be the temporary directory. So, the question is, does Java honours TMPDIR ?

Found this with the help of Google. Too bad, Java DOESN'T honour TMPDIR variable. To proof the point, I wrote my very first Java program (FYI, I do not like programming languages start with letter J :-), almost the first except Hello World.

$ cat a.java
import java.io.*;

public class a {
        public static void main(String[] args) {
                String tmpdir=System.getProperty("java.io.tmpdir");
                System.out.println("Dir: " + tmpdir + "\n");
        }
}

$ uname -a
SunOS chihung 5.10 Generic_118833-36 sun4u sparc SUNW,UltraSPARC-IIi-cEngine

$ java -version
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)

$ cat a.java
import java.io.*;

public class a {
        public static void main(String[] args) {
                String tmpdir=System.getProperty("java.io.tmpdir");
                System.out.println("Dir: " + tmpdir);
        }
}

$ javac a.java

$ TMPDIR=/a/b/c java a
Dir: /var/tmp/

$ java a
Dir: /var/tmp/

$ java -Djava.io.tmpdir="/a/b/c" a
Dir: /a/b/c

Labels: ,

0 Comments:

Post a Comment

<< Home