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

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.


Solution 1:

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


Example:

enter image description here

enter image description here

enter image description here

Solution 2:

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

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).

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

Solution 3:

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

Solution 4:

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

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

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