Monday, April 09, 2007

Java System Properties

After understand that Java does not honour TMPDIR, I really want to know what are the default system properties in Java. Hence, I wrote my 2nd Java program to list out the default values of all the system properties.

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

public class b {
        public static void main(String[] args) {
                String value;
                String keys[]={
                        "java.version",
                        "java.vendor",
                        "java.vendor.url",
                        "java.home",
                        "java.vm.specification.version",
                        "java.vm.specification.vendor",
                        "java.vm.specification.name",
                        "java.vm.version",
                        "java.vm.vendor",
                        "java.vm.name",
                        "java.specification.version",
                        "java.specification.vendor",
                        "java.specification.name",
                        "java.class.version",
                        "java.class.path",
                        "java.library.path",
                        "java.io.tmpdir",
                        "java.compiler",
                        "java.ext.dirs",
                        "os.name",
                        "os.arch",
                        "os.version",
                        "file.separator",
                        "path.separator",
                        "line.separator",
                        "user.name",
                        "user.home",
                        "user.dir",
                };

                for (String key: keys) {
                        value=System.getProperty(key);
                        System.out.println(key + "=" + value);
                }

        }
}


$ java b
java.version=1.5.0_07
java.vendor=Sun Microsystems Inc.
java.vendor.url=http://java.sun.com/
java.home=/usr/jdk/instances/jdk1.5.0/jre
java.vm.specification.version=1.0
java.vm.specification.vendor=Sun Microsystems Inc.
java.vm.specification.name=Java Virtual Machine Specification
java.vm.version=1.5.0_07-b03
java.vm.vendor=Sun Microsystems Inc.
java.vm.name=Java HotSpot(TM) Client VM
java.specification.version=1.5
java.specification.vendor=Sun Microsystems Inc.
java.specification.name=Java Platform API Specification
java.class.version=49.0
java.class.path=.
java.library.path=/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/client:/usr/jdk/instances/jdk1.5.0/jre/lib/sparc:/usr/jdk/instances/jdk1.5.0/jre/../lib/sparc:/lib:/usr/lib:/usr/sfw/lib:/usr/dt/lib:/usr/X11R6/lib:/usr/lib
java.io.tmpdir=/var/tmp/
java.compiler=null
java.ext.dirs=/usr/jdk/instances/jdk1.5.0/jre/lib/ext
os.name=SunOS
os.arch=sparc
os.version=5.10
file.separator=/
path.separator=:
line.separator=

user.name=chihung
user.home=/export/home/chihung
user.dir=/export/home/chihung

If you were to run java as a server, the default library path changes accordingly. If you look one of the library paths, you will see "java -client" (default) and "java -server" load in different libjvm.so sharable object. Does anyone know exactly the difference between the 2 libjvm.so, apart from the way they define the young and old generations.

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

$ java -server b > b.server

$ java -d64 -server b > b.server.d64

$ java -client b > b.client

$ diff b.server b.client
10c10
< java.vm.name=Java HotSpot(TM) Server VM
---
> java.vm.name=Java HotSpot(TM) Client VM
16c16
< java.library.path=/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/server:/usr/jdk/instances/jdk1.5.0/jre/lib/sparc:/usr/jdk/instances/jdk1.5.0/jre/../lib/sparc:/lib:/usr/lib:/usr/sfw/lib:/usr/dt/lib:/usr/X11R6/lib:/usr/lib
---
> java.library.path=/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/client:/usr/jdk/instances/jdk1.5.0/jre/lib/sparc:/usr/jdk/instances/jdk1.5.0/jre/../lib/sparc:/lib:/usr/lib:/usr/sfw/lib:/usr/dt/lib:/usr/X11R6/lib:/usr/lib

$ diff b.server b.server.d64
10c10
< java.vm.name=Java HotSpot(TM) Server VM
---
> java.vm.name=Java HotSpot(TM) 64-Bit Server VM
16c16
< java.library.path=/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/server:/usr/jdk/instances/jdk1.5.0/jre/lib/sparc:/usr/jdk/instances/jdk1.5.0/jre/../lib/sparc:/lib:/usr/lib:/usr/sfw/lib:/usr/dt/lib:/usr/X11R6/lib:/usr/lib
---
> java.library.path=/usr/jdk/instances/jdk1.5.0/jre/lib/sparcv9/server:/usr/jdk/instances/jdk1.5.0/jre/lib/sparcv9:/usr/jdk/instances/jdk1.5.0/jre/../lib/sparcv9:/lib:/usr/lib:/usr/sfw/lib:/usr/dt/lib:/usr/X11R6/lib:/usr/lib
21c21
< os.arch=sparc
---
> os.arch=sparcv9

$ cd /usr/jdk/instances/jdk1.5.0/jre/lib/sparc

$ ls -l client server
client:
total 36778
drwxr-xr-x   2 root     bin          512 Mar 21 10:20 64
-rw-r--r--   1 root     bin         1423 May  3  2006 Xusage.txt
-r--r--r--   1 root     other    11886592 Mar 21 10:21 classes.jsa
lrwxrwxrwx   1 root     root          13 Mar 21 10:20 libjsig.so -> ../libjsig.so
-rwxr-xr-x   1 root     bin      6879100 May  3  2006 libjvm.so
-rwxr-xr-x   1 root     bin        41072 May  3  2006 libjvm_db.so

server:
total 19898
drwxr-xr-x   2 root     bin          512 Mar 21 10:20 64
-rw-r--r--   1 root     bin         1423 May  3  2006 Xusage.txt
lrwxrwxrwx   1 root     root          13 Mar 21 10:20 libjsig.so -> ../libjsig.so
-rwxr-xr-x   1 root     bin      10127532 May  3  2006 libjvm.so
-rwxr-xr-x   1 root     bin        41072 May  3  2006 libjvm_db.so

Labels: ,

1 Comments:

Blogger Ah Choo said...

If you have the helpful tool by the name of ant from the Apache Projects,
executing "ant -diagnostics" will have provided you with the details.

Or

import java.util.*;
public class ListProperties {
public static void main(String[] args) {
Properties p = System.getProperties();
for (Enumeration en = p.keys(); en.hasMoreElements();){
String key = en.nextElement().toString();
System.out.println(key+"::"+p.getProperty(key));
}
}

}

4:15 PM  

Post a Comment

<< Home