如何从 Eclipse 运行批处理脚本(.bat 文件)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1090355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:49:41  来源:igfitidea点击:

How to run a batch script (.bat file) from eclipse

eclipsebatch-file

提问by Csaba_H

My Java application is started by running a set of commands that are present in a batch file (.bat file). And I imported this into Eclipse workbench. How do I execute the batch file from Eclipse. Similar to the one in command line, I directly give "path:\myBatchfile.bat". Is there any way I can do directly from Eclipse.

我的 Java 应用程序是通过运行批处理文件(.bat 文件)中的一组命令来启动的。我将它导入到 Eclipse 工作台中。如何从 Eclipse 执行批处理文件。与命令行类似,我直接给出“path:\myBatchfile.bat”。有什么办法可以直接从 Eclipse 中进行。

回答by Csaba_H

You can call your .bat file using the External Toolsfeature (in the Run menu).

您可以使用外部工具功能(在运行菜单中)调用您的 .bat 文件。



Example:

例子:

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

回答by Mercer Traieste

Or, you could create an Ant build file, which can call external applications.

或者,您可以创建一个 Ant 构建文件,该文件可以调用外部应用程序。

This will give you the advantage to call the .bat not only from Eclipse, but other IDE's, or from command line (on any machine).

这将使您不仅可以从 Eclipse 中调用 .bat,还可以从其他 IDE 或命令行(在任何机器上)调用 .bat。

http://ant.apache.org/manual/Tasks/exec.html

http://ant.apache.org/manual/Tasks/exec.html

回答by SpaceTrucker

You can also run a batch file (or any other executable file) by opening it with the System Editor. Use Open With -> System Editor.

您还可以通过使用系统编辑器打开批处理文件(或任何其他可执行文件)来运行它。使用Open With -> System Editor.

回答by Paul Verest

Associate with text Editor by right-click - Open With (As of 2017 there is no plugin with special editor )

通过右键单击与文本编辑器关联 - 打开方式(截至 2017 年,没有带有特殊编辑器的插件)

To run install plugin like https://marketplace.eclipse.org/content/easyshell
You can easy run .shwith Git Bash as well

运行安装插件如https://marketplace.eclipse.org/content/easyshell
您也可以.sh使用 Git Bash轻松运行

or https://github.com/culmat/eExplorer

https://github.com/culmat/eExplorer