There is only one method we have to use of the System class is "getProperty()". The method System.getProperty() holds the one argument which is of type String. So if any one who is beginner to this and using notepad, then I suggest to read the argument carefully and type it as it is in the given example. Because if there will any spelling error in it, there are chances of giving it a runtime error. So be very careful about spelling while typing the progrm.
class SystemClass
{
public static void main(String[] ar)
{
System.out.println("1 : " + System.getProperty("java.version"));//Current Version Name
System.out.println("2 : " + System.getProperty("user.name"));//Current Username
System.out.println("3 : " + System.getProperty("user.dir"));//Current user driectory
System.out.println("3 : " + System.getProperty("user.home"));//Home directory of the user
System.out.println("4 : " + System.getProperty("os.name"));//Operating System name
System.out.println("5 : " + System.getProperty("os.arch"));//Operating System Architecture Ex : x86= Microprocessor 8086 architecture
System.out.println("6 : " + System.getProperty("os.version"));//Operating System version
System.out.println("7 : " + System.getProperty("java.io.tmpdir"));//Temporary directory of user
System.out.println("8 : " + System.getProperty("java.ext.dirs"));
System.out.println("9 : " + System.getProperty("java.specification.version"));//Version of java
System.out.println("10 : " + System.getProperty("java.specification.vendor"));//Vendor of java
System.out.println("11 : " + System.getProperty("java.specification.name"));//name of java Specification
System.out.println("12 : " + System.getProperty("java.class.path")); //Classpath of JDK
System.out.println("13 : " +System.getProperty("java.class.version"));//Version of java class
System.out.println("14 : " +System.getProperty("path.separator"));//path separator of classpath
System.out.println("15 : " +System.getProperty("line.separator"));//it will show two blank line
System.out.println("16 : " +System.getProperty("java.vm.name"));//name of JavaVirtualMachine
System.out.println("17 : " +System.getProperty("java.vm.vendor"));//Vendor of java Virtual Machine
System.out.println("18 : " +System.getProperty("java.vm.version"));// version of java virtual machine
System.out.println("19 : " +System.getProperty("java.vm.specification.name"));//specification name of java virtual machine
System.out.println("20 : " +System.getProperty("java.vm.specification.version"));//specification version of java virtual machine
System.out.println("21 : " +System.getProperty("java.vm.specification.vendor"));//vendor of specification of java virtual machine
System.out.println("22 : " +System.getProperty("java.vendor.url"));//main url of java
System.out.println("23 : " +System.getProperty("java.vendor"));
System.out.println("24 : " +System.nanoTime());
//System.load(System.getProperty("user.dir") + "\\" + "MyClass.java");
}
}
Type above example and save it as the name you want and run with the name of class. The output of the above code will give something like below.
No comments:
Post a Comment