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: 
I would suggest just exporting a jar file for your project. All the libraries will be packaged together in the jar files(including TestNG) and you can simply double click on the jar file to start your tests. Make a runner file that calls all the tests you have to run one by one.

External resources (if any), will have to be available for the jar file though. The external resources might include your test data (if any) or Portable browsers (example portable firefox).

**Steps**:

* Right click on Project -> Export -> Runnable jar file
* Give a name and file path for the jar file
* Select option - *Extract required libraries into generated JAR*
* And Finish

**Troubleshooting**:

Check the java version for the machines that you will be running your jar file on. Programs compiled with java 7 will mostly not run if the machine has java 6. Either compile with java 6 or update the jre on the target machines.

If the jar file does not launch, try using Jarfix.
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

```