If you use Eclipse then you can Export a project to jar with right-button click -> Export and then you have a choice of Jar/Executable Jar.
Well I need to create Executable Jar but then I have no flexible choice of files to include in the JAR as I do have with just Jar option. Why is that?
Java Eclipse: Difference between exporting as a JAR and exporting as a Runnable JAR
Export as ‘Executable Jar’ will take a launch configuration and pack everything that is needed for the launch into a Jar, so selecting the files to include is not necessary there. It is a convenience functionality from Eclipse to quickly create ready-to-go executable jars with only a click.
Export as ‘Jar’ will give you the choice of selecting the resources that you want to have in the Jar. It will also allow you to specify a main class and will then create an executable Jar by creating the necessary manifest file. (Just follow the ‘export jar’ wizard to the last page, at the bottom you will find an input box for selecting the main class. Selecting one will create an executable jar)
Remember: An executable Jar is just a normal Jar with a MANIFEST.MF file that specifies the main class to call when executed.