程序参数和VM参数有什么区别?
答
程序参数的参数传递给您的程序和args
阵列的主要方法可用
public static void main(String[] args)
VM参数传递到虚拟机,其目的是指导虚拟机做些什么。您可以执行诸如控制堆大小等操作,您可以通过调用System.getProperty()
来访问它们,如上所述。
答
计划ARGS通过您的主要(字符串ARGS [])方法的
答
程序参数进入main()方法的ARGS []可用:
public static void main(String[] args) // here
答
- 程序参数 - 我们通常传入我们程序的参数。这个类型参数可以通过main方法中的“args”字符串数组访问。
- VM参数 - 传递给Java解释器的参数。
答
[![enter image description here][1]][1]Program Argument: Program arguments are arguments that are passed to your application, which are accessible via the "args" String array parameter of your main method.
VM Argument: : VM argument are environment or system argument that needed by JVM to execute program. VM arguments is read from system property as below java instruction.
System.getProperty(sysProp1)
Code Snippet:
public static void main(String[] args) {
String sysProp1 = "sysProp1";
System.out.println("\t System Propery Name:" + sysProp1 + ", Value:" + System.getProperty(sysProp1));
System.out.println("\t Program Variable Test Propery Name:" + args[0]);
}
There are Two way to pass these two params values.
From Eclipse:
[1]: https://i.stack.imgur.com/7c0dv.jpg
Command Line Argument:
java -cp projectJar-2.0-SNAPSHOT-jar-with-dependencies.jar com.first.jobs.IndexJob testing -DsysProp1=testing
非常明确的答案:) – 2017-03-07 08:39:22