i have one selenium project, i need to deploy as jar file how to do that?
i used following tools/api's

  1. Selenium Web driver+java
  2. poi
  3. JXL
  4. TestNG
  5. AUT Reporter i don't have Main Method. Runnable jar able to run on any system which has jdk.
    Why I need runnable jar? i need it for deployment to client who has only jdk.
  • Creating a maven project and then using it's plugins like Maven Shade or One-Jar or assembly , you can create one executable jar file. You may want to take look at this
    – MKay
    Mar 16, 2016 at 10:33
  • @Mitaleek hey hi, nice solution, but i don't want to change existing project to maven project it will be hectic job so... Mar 16, 2016 at 10:35
  • Rather, it would be hectic job to get all dependent entities in single jar without Maven. Still if you want to avoid maven Check this answer on SO
    – MKay
    Mar 16, 2016 at 11:14
  • @Mitaleek i tried what you said, still no luck i got runnable jar but when i place on same jar on differant system its not running... Mar 18, 2016 at 9:40
  • Why you want to create Jar file. Please mentioned in Questions. SO can give other ways If possible.
    – Sagar007
    Mar 19, 2016 at 7:25

2 Answers 2


As per your question I understood that you are not using maven.So you are running the scripts based on your testng.xml file.So you can use this code in to separate class with main method. So that you are able make RunnableJar.

TestListenerAdapter tla = new TestListenerAdapter();
TestNG testng = new TestNG();
List<String> suites = Lists.newArrayList();
suites.add("c:/tests/testng1.xml");//path to xml..

I hope this solution works for you.

  • i have 5 class (5 different java files) like Test, testA, testb,testC so on where Test class has BeforeTest ,Aftertest and Test class includes other class(testA,Testb,testc), testa,testB,Testc extends Test class. in this case may i convert whole project to TestNG or Main class(TEST Class) only need to Be converted Mar 21, 2016 at 6:00
  • which option i need to choose while creating runnable jar? created jar able to run on othre system which has only jdk? Mar 21, 2016 at 6:11
  • Please select the Runnable jar option from eclipse while you are creating a jar file from eclipse
    – QAMember
    Mar 21, 2016 at 7:27
  • No need change any of your 5 classes, just add this code in to a new class with main method
    – QAMember
    Mar 21, 2016 at 7:28
  • @ QAMember iam asking for "Select an appropriate library handling strategy." Mar 21, 2016 at 7:31

If you are using Eclipse IDE, it provides an option to Export as JAR/Runnable JAR. Please follow below steps:

  • From the menu bar's File menu, select Export.
  • Expand the Java node and select Runnable JAR file. Click Next.
  • Select a 'Java Application' launch configuration to use to create a runnable JAR.
  • In the Export destination field, either type or click Browse to select a location for the JAR file.
  • Select an appropriate library handling strategy.

Alternatively you can even export as a JAR and use Launch4J to run as Win application.

  • i tried above mentioned steps "I don't have main method" so unable to create jar. which option i need to choose for library handling strategy. Mar 21, 2016 at 4:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.