There are various system properties that we need to use during our programs to perform some action or access some file.
There are some commonly used properties.
These are following keys that can be used to find out the property.
"System" class has a properties Object associated with it that is used to find out those properties.
There are some commonly used properties.
Key | Meaning |
---|---|
"file.separator" | Character that separates components of a file path. This is "/ " on UNIX and "\ " on Windows. |
"java.class.path" | Path used to find directories and JAR archives containing class files. Elements of the class path are separated by a platform-specific character specified in the path.separator property. |
"java.home" | Installation directory for Java Runtime Environment (JRE) |
"java.vendor" | JRE vendor name |
"java.vendor.url" | JRE vendor URL |
"java.version" | JRE version number |
"line.separator" | Sequence used by operating system to separate lines in text files |
"os.arch" | Operating system architecture |
"os.name" | Operating system name |
"os.version" | Operating system version |
"path.separator" | Path separator character used in java.class.path |
"user.dir" | User working directory |
"user.home" | User home directory |
"user.name" | User account name |
These are following keys that can be used to find out the property.
"System" class has a properties Object associated with it that is used to find out those properties.
Example:-
public class MyProperties {
public static void main(String ar[])
{
System.out.println("user.dir-"+System.getProperty("user.dir"));
System.out.println("user.home-"+System.getProperty("user.home"));
System.out.println("user.name-"+System.getProperty("user.name"));
System.out.println("file.separator-"+System.getProperty("file.separator"));
System.out.println("java.class.path-"+System.getProperty("java.class.path"));
System.out.println("java.home-"+System.getProperty("java.home"));
System.out.println("java.vendor-"+System.getProperty("java.vendor"));
System.out.println("java.vendor.url-"+System.getProperty("java.vendor.url"));
System.out.println("java.version-"+System.getProperty("java.version"));
System.out.println("line.seprator-"+System.getProperty("line.seprator"));
System.out.println("os.arch-"+System.getProperty("os.arch"));
System.out.println("os.name-"+System.getProperty("os.name"));
System.out.println("os.version-"+System.getProperty("os.version"));
System.out.println("path.seprator-"+System.getProperty("path.seprator"));
}
}
No comments:
Post a Comment