Difference Program Arguments VM Arguments

Difference Program Arguments VM Arguments

Program Argument: This arguments are passed to the program and available through args array of main(String args[]) method as shown example below:

  • ProgramArgument.java:

  • As you see above we will pass two program argument and print its value. I will use eclipse to pass argument and run:

Difference Program Arguments VM Arguments

  • Now run this program it will print value as below:

Difference Program Arguments VM Arguments

VM Arguments: This arguments are passed to the virtual machine which instruct VM to take some action.You could pass VM argument memory size, file path etc… which you can access by calling to System.getProperty() as shown in example below:

  • VMArgument.java:

  • We will pass some VM argument as below from eclipse:

Difference Program Arguments VM Arguments

  • When you run this program it will print below value on console:

Difference Program Arguments VM Arguments

  • For more information please refer oracle document here

Leave a Reply

Your email address will not be published. Required fields are marked *