我有一个非常简单的 main 方法来打印传入的参数。如果我通过传递“ this ”使用“ant run”运行程序 ”和“ that运行程序。打印出来的会是这样的:
run:
[java] Hello updatetool.
[java] Started with these parameters:
[java] 1. backup location, absolute path:this
[java] 2. new install location, absolute path:that
BUILD SUCCESSFUL
然后我像这样添加“-version”jvm参数:
<target name="run" depends="echo"
description="Run application from development environment">
<java classname="${program.main}"
classpathref="compile.classpath"
fork="true">
<jvmarg value="-Xmx${MAX_MEMORY}m"/>
<jvmarg value="-Xms${MIN_MEMORY}m"/>
<jvmarg value="-XX:NewSize=${YOUNG_MEMORY}m"/>
<jvmarg value="-version"/> <<<<<<<<<<<<<<***************+++++++++
<arg value="this"/>
<arg value="that"/>
</java>
</target>
但是程序输出变成了这样:
run:
[java] java version "1.7.0_06"
[java] Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
[java] Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)
BUILD SUCCESSFUL
“这个”没有打印出来 ”和“ that。我的 Java 文件没有其他更改。
为什么?
我在linux机器上运行。
这是我的主要方法:
public static void main(String[] args)
{
// TODO Auto-generated method stub
System.out.println("Hello updatetool.");
int numOfParameters = 2;
if(args == null || args.length < numOfParameters)
{
System.out.println("Not enough parameters. Usage of this tool:"
+ "\t\n1. backup location, absolute path;"
+ "\t\n2. new install location, absolute path;"
);
System.exit(1);
}
else
{
System.out.println("Started with these parameters:"
+ "\t\n1. backup location, absolute path:" + args[0]
+ "\t\n2. new install location, absolute path:" + args[1]
);
System.exit(0);
}
}