如何使用命令行参数执行 jar [英] How to execute jar with command line arguments
问题描述
可能的重复:
将参数传递给 Java 解释器所需的 JAR一个>
如何向 jar 中的文件提供命令行输入我有一个 jar 文件 hello.jar,其中有一些我想用两个参数从命令行执行的 execute.java 文件;我怎样才能做到这一点我提到了一个 executable.java 作为清单文件中的主类并使用 ant我必须使用命令行参数从 ant run 运行此文件
how to provide command line input to a file which is in a jar I have a jar file hello.jar with some say execute.java file which i want to execute from command line with two arguments;how can i achive this i have mentioned a executable.java as a main class in a manifest file and using ant i have to run this file from ant run with command line arguments
感谢和问候萨马斯
推荐答案
在命令 shell 中试试这个:
Try this in the command shell:
java -cp your-classpath-dependencies-here -jar hello.jar "arg1" "arg2"
在 Ant 中使用
内置任务执行此操作:
Do it in Ant with the <java>
built-in task:
http://ant.apache.org/manual/Tasks/java.html
这篇关于如何使用命令行参数执行 jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!