Title: System Properties
Course: CPS 261: Advanced Java Concepts ~ DL & MM MASTER

System Properties

In this video, we go over some of the java properties that you can access.

Program used in the video: SystemProperties.java

import java.util.Properties;


public class SystemProperties {

	
	public static void main(String[] args) {
		String userDir = System.getProperty("user.dir");
		System.out.println("user.dir=" + userDir);
		
		String lineSeparator = System.getProperty("line.separator");
		for (int i=0; i < lineSeparator.length(); i++)
	        System.out.println("int(line.separator): " +
                    (int)(lineSeparator.charAt(i)));
		
		String fileSeparator = System.getProperty("file.separator");
	    System.out.println("file.separator: " + fileSeparator);
	
	    String version = System.getProperty("java.version");
	    System.out.println("Java.version="+version);
	
	    String osName = System.getProperty("os.name");
	    System.out.println("os.name="+osName);
	
	    String userName = System.getProperty("user.name");
	    System.out.println("user.name="+ userName);
	
	    String userHome = System.getProperty("user.home");
	    System.out.println("user.home="+ userHome);
	
	    System.out.println("**********************************************");
	
	    Properties props;
	    props = System.getProperties();
	    props.list(System.out);
		

	}

}


Last Updated: July 30, 2013 10:56 PM