How to make a runnable jar file?

Solution 1:

The command line

java -jar file.jar

Will run your jar file if it has a Main-Class defined as explained here.

You can use that command in a shell script.

Solution 2:

You can create a runnable jar using NetBeans IDE or Eclipse IDE by just providing the main class to run. Rest of the things it will take automatically. That class must be having a main() method in it. Then you can run that jar file using java -jar yourjarfile.jar