How to display all system properties in Java

This code displays all system (jvm) properties in java :

import java.util.Iterator;
import java.util.Properties;

public class Test {

 public static void main(String[] args) {
   Properties properties = System.getProperties();
   Iterator<Object> iter = properties.keySet().iterator();
   while(iter.hasNext()){
    String key = (String) iter.next();
    System.out.println(key + " = " + properties.getProperty(key));
   }
  }
 }

 

Here is a set of default system properties you can access:

java.runtime.name
sun.boot.library.path
java.vm.version
user.country.format
java.vm.vendor
java.vendor.url
path.separator
java.vm.name
file.encoding.pkg
user.country
user.script
sun.java.launcher
sun.os.patch.level
java.vm.specification.name
user.dir
java.runtime.version
java.awt.graphicsenv
java.endorsed.dirs
os.arch
java.io.tmpdir
line.separator
java.vm.specification.vendor
user.variant
os.name
sun.jnu.encoding
java.library.path
java.specification.name
java.class.version
sun.management.compiler
os.version
user.home
user.timezone
java.awt.printerjob
file.encoding
java.specification.version
java.class.path
user.name
java.vm.specification.version
sun.java.command
java.home
sun.arch.data.model
user.language
java.specification.vendor
user.language.format
awt.toolkit
java.vm.info
java.version
java.ext.dirs
sun.boot.class.path
java.vendor
file.separator
java.vendor.url.bug
sun.io.unicode.encoding
sun.cpu.endian
sun.desktop
sun.cpu.isalist

You like this content ? Share it with you entourage !

Leave a Reply

Your email address will not be published.