如何将参数从windows批处理脚本传递给java

问题描述:

我需要阅读一些参数,这些参数是在我的java程序中的windows批处理脚本中定义的... 如何定义参数..?对于例如 ,我需要读取脚本中定义的变量; 变量v = XYX如何将参数从windows批处理脚本传递给java

我试着定义像(在脚本中);

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 

你要打电话给你的第一类的主要方法

的Java com.xyz.MyClass -DVARIABLE = XYX

+0

感谢这个工作正常 – Ratha 2012-04-25 18:45:49