如何将参数从Windows批处理脚本传递到java

时间:2012-04-16 10:28:12

标签: windows batch-file

我需要在java程序中读取一些参数,这些参数在windows批处理脚本中定义... 我该如何定义参数..? 例如 我需要读取脚本中定义的变量; 变量v = XYX

我尝试定义喜欢(在脚本中);

java  -Dvariable=XYX

但得到以下异常;

Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)

where options include:
    -client       to select the "client" VM

1 个答案:

答案 0 :(得分:0)

你必须先调用你班级的主要方法

  

java com.xyz.MyClass -Dvariable = XYX