简体   繁体   English

如何使用文件中的不同命令行参数运行相同的Java程序

[英]How to run the same java program with different command line arguments from a file

I want to run a java program SampleProgram.java 10 times with different parameters. 我想用不同的参数运行Java程序SampleProgram.java 10次​​。 I checked running the java program from .bat file. 我检查了从.bat文件运行Java程序的情况。 My question is that is it possible to run the same program SampleProgram multiple times like the following : 我的问题是是否可以多次运行相同的程序SampleProgram ,如下所示:

java -jar SampleProgram.jar argument1 argument2
java -jar SampleProgram.jar argument3 argument4
java -jar SampleProgram.jar argument5 argument6

Will writing the above lines in a batch file, testRun.bat and running runTest.bat run the java programs with different arguments? 将上述行写入批处理文件testRun.bat中并运行runTest.bat可以使用不同的参数运行Java程序吗?

You probably need to launch them with start /B to launch them in background otherwise your batch will launch them sequentially instead of launching them in parallel. 您可能需要使用start /B启动它们以在后台启动它们,否则您的批处理将按顺序启动它们,而不是并行启动它们。 So try this: 所以试试这个:

start /B java -jar SampleProgram.jar argument1 argument2
start /B java -jar SampleProgram.jar argument3 argument4
start /B java -jar SampleProgram.jar argument5 argument6

As it is done in this answer . 就像在这个答案中所做的那样。

暂无
暂无

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

相关问题 如何使用来自java程序的参数运行bat文件? (尝试使用命令行工具自动化) - How to run bat file with arguments from a java program? (Trying to automate using a Command Line Tool ) Maven:如何从传递 arguments 的命令行运行 a.java 文件 - Maven: How to run a .java file from command line passing arguments 如何运行从Java程序中获取命令行参数的Python程序 - How to Run a Python Program that Takes Command-Line arguments from within a Java Program 从命令行在Java程序中传递运行参数会产生错误 - Passing run arguments in a java program from command line gives an error 当 mysql 连接器位于同一项目中时,如何从命令行运行连接数据库的 Java 程序? - How to run a database connected Java program from the command line, when the mysql connector is located in the same project? 如何从命令行通过vm参数运行Java项目? - How to run a java project with vm arguments from command line? 如何从命令行使用 arguments 运行 Java 方法? - How to run Java method with arguments from command line? 如何从线程的run方法内部的单独文件访问和/或读取命令行参数(Java套接字编程) - How to access and/or read command line arguments from a separate file inside the run method of a thread (java socket programming) "如何在 Windows 上从命令行运行 Java 程序?" - How do I run a Java program from the command line on Windows? 如何让java getRuntime()。exec()运行带参数的命令行程序? - How to get java getRuntime().exec() to run a command-line program with arguments?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM