简体   繁体   English

如何使用批处理文件运行两个Java应用程序?

[英]How can i run two java applications using a batch file?

I want to run two java applications located in two different projects in eclipse at the same time automatically , I guess using a batch file is the best way to do this. 我想同时自动运行eclipse中位于两个不同项目中的两个Java应用程序,我想使用批处理文件是执行此操作的最佳方法。 Is that correct? 那是对的吗? or there are better ways? 还是有更好的方法?

If it's the best way, what would be the syntax for the batch file? 如果这是最好的方法,则批处理文件的语法是什么? Do I need to have jar files for the projects? 我需要项目的jar文件吗? Does batch files work only on windows? 批处理文件仅在Windows上有效吗?

start java path\of\first\class
start java path\of\second\class

This will launch both at the same time, assuming that's what you're looking for. 假设这就是您想要的,这将同时启动这两个程序。 The applications don't have to be packed in a jar, you can also pass the path of the class containing the Main you'd like to run. 应用程序不必打包在jar中,您也可以传递包含要运行的Main的类的路径。 You might have to pass a few more arguments (such as classpath), depending on your setup. 您可能必须再传递一些参数(例如classpath),具体取决于您的设置。

And yes, this will only work on Windows (and possibly on Dos). 是的,这仅适用于Windows(可能适用于Dos)。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM