Question: I am a noob in Java and automation so please bear with me if I get the terminology wrong.

I have a class file that can open a browser and navigate to google.com and then closes the browser. There’s another class file that does the same but goes to yahoo.com.

I can run this from eclipse and everything works fine.

However,  I need to know if I can run both the test cases one after the other without opening Eclipse and only by using batch files (.bat files) on Windows.

I would appreciate a clear step by step instruction. Thanks in advance.

Answer: 
From your question I'm assuming that you want to run your automation tests built using java one after the other using a batch file.

Yes, you can run the tests using a batch file. Open a notepad and add your tests (binaries) like below and save is as YourTestFilename.bat

```
echo off
% java C:/Test/Test1
% java C:/Test/Test2
% java C:/Test/Test3

```

Or

```
% java C:/Test/Test1
% java C:/Test/Test2
% java C:/Test/Test3

```

Double click the batch file. If you want to schedule it, you can use Task Scheduler in windows to run your batch file. Checkout the below links to see how to schedule a task.

<http://windows.microsoft.com/en-au/windows/schedule-task#1TC=windows-7>
<http://www.7tutorials.com/how-create-task-basic-task-wizard>​
In eclipse you can export your test cases as runnable java jars. and using the following commands create a batch file to run them sequentially/simultaneously-

Sequentially:

```
java -jar pathToRunnableJars/test1.jar
java -jar pathToRunnableJars/test2.jar
java -jar pathToRunnableJars/test3.jar
java -jar pathToRunnableJars/test4.jar

```

Simultaneously:

```
start java -jar pathToRunnableJars/test1.jar
start java -jar pathToRunnableJars/test2.jar
start java -jar pathToRunnableJars/test3.jar
start java -jar pathToRunnableJars/test4.jar

```