Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between program arguments and VM arguments?

Tags:

java

eclipse

I found only when I put -Dcontext=web into VM arguments, the value can be read by System.getproperty method. I am wondering what's the difference between those two?

like image 843
user705414 Avatar asked Apr 22 '11 02:04

user705414


People also ask

What is the use of VM arguments?

VM arguments are typically values that change the behaviour of the Java Virtual Machine (JVM). For example, the -Xmx256M argument allows the Java heap to grow to 256MB. The Eclipse runtime is also configurable via many system properties which can be passed as VM arguments in the form: -DpropertyName=propertyValue.

What is VM arguments in Intellij?

Intellij allows you to specify two types of arguments when running a Java program: VM Options. Enables you to modify attributes of the JVM, including stack/heap memory allocation, system properties, GC flags, etc.

Where do I put VM arguments?

Step 1: Open the IDE and right-click on the application in which you want to pass VM arguments. Step 2: Click on the Run As » Run Configurations… Step 3: Click on the Arguments tab and in the VM arguments: box, type the arguments that you want to pass.

What are VM options in Java?

There are three types of options that you can add to your JVM, standard, non-standard and advanced options. If you apply an advanced option, you always precede the option with -XX: . Similarly if you're using a non-standard option, you'll use -X . Standard options don't prepend anything to the option.


1 Answers

Program arguments are arguments passed to your program and available in the args array of your main method

 public static void main(String[] args) 

VM arguments are passed to the virtual machine and are designed to instruct the VM to do something. You can do things like control the heap size, etc. They can be accessed by your program via a call to System.getProperty() as you described.

like image 133
Chris Thompson Avatar answered Sep 27 '22 01:09

Chris Thompson