简体   繁体   English

我如何将参数从Windows批处理脚本传递给Java

[英]How can i pass parametersfrom a windows batch script to java

I need to read some parameters , which are defined in a windows batch script,in my java program... How can i define parameters..? 我需要阅读一些参数,这些参数是在Windows批处理脚本中的Java程序中定义的。我如何定义参数..? for eg I need to read a variable which is defined in the script; 例如,我需要读取脚本中定义的变量; variable v=XYX 变量v = XYX

i tried defining like(in the script); 我尝试定义(在脚本中)like;

java  -Dvariable=XYX

but getting following exception; 但得到以下例外;

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

You have to call the main method of your class first 您必须先调用类的main方法

java com.xyz.MyClass -Dvariable=XYX java com.xyz.MyClass -Dvariable = XYX

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Windows批处理文件或linux shell脚本中传递10个以上的参数 - How can I pass more than 10 arguments in windows batch file or linux shell script 如何将数据库名称从批处理传递到mysql脚本 - how can I pass database name from batch to mysql script 如何在远程Windows计算机上从Java运行批处理脚本 - How can I run a batch script from java on a remote windows machine 如何将带点的批处理参数传递给powershell脚本? - How can I pass batch arguments with dots into a powershell script? 如何在C#中的Windows服务中执行批处理脚本? - How can I execute a batch script in a windows service in C#? 我可以在 Windows 中将 Sass 与批处理脚本一起使用吗 - Can I use Sass with a batch script in Windows 如何遍历文件夹中的文件以创建参数列表以传递到Windows批处理文件中的另一个脚本中? - How do I loop through files in folder to create a parameter list to pass into another script in a Windows batch file? 如何将Windows批处理脚本变量传递给管道命令 - How to pass a windows batch script variable to a piped command 如何使用批处理脚本在 Windows 10 中获取 Windows 注册表项的值 - How can I get the value of a windows registry key in windows 10 with batch script 如何使用 Windows 批处理脚本将空 ASCII 字符 (nul) 写入文件? - How can I write a null ASCII character (nul) to a file with a Windows batch script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM