Steps to Create Executable JAR file in EclipseA picture is worth more than a thousand words, that's why I have provided all steps by taking screenshots. You can quickly learn how to create executable JAR for your Java application in Eclipse, by just looking at these screenshot. They are arranged from start to end. Which means first image is for first step and last image is for last step. By the way, if your application is dependent upon some other JAR files e.g. third-party library, then don't need to include them inside JAR. All you need to do is include them inside your Java Classpath. Java is smart enough to pick classes from those JAR. Also remember to include main method or entry point of your Java program, while creating executable JAR, as you can not run a Java program without main method, as discussed here.
Choose Java and select JAR file for exporting
Now select the source and resources you want to export into JAR file. After selecting src folder and any resource, select the destination folder, where you want your JAR file to be created. Also don't forget to check option "compress the content of JAR file". This will reduce size of executable JAR file. If you want you can finish the process in this step, but you can also go one step further to save these instruction of executable JAR file creation for future use.
In this step you can save all instruction into a "JAR description" file for future use. This will create a description file e.g. Test.jardesc in the chosen folder.
This is an important step, because you are going to generate the manifest file, don't forget to choose main class. This is important to make your JAR an executable JAR file. Remember main method is entry point of any Java application.
You are done with creating executable JAR file. Now you can go to the target folder, which you have chose in previous steps to see both JAR file as well .jardesc file to recreate JAR file again and again. This time you don't need to include main class as well, as those are already included.
After making code changes, if you want to create a new JAR file, you don't need to go through all previous steps. This time, just select your JAR description file and say "create JAR", a right click menu option in Eclipse. This will create another JAR file in same folder. You can double check timestamp of JAR file.
That's all about How to create or make Executable JAR file in Eclipse IDE. By following these steps you can export your Java program as executable JAR, which allow you to share your program with your user, client and any one who wants to take a look. I strongly suggest to save instruction to export JAR file, so that you don't need to run through all these steps again and again. Next time, when you update your code, just click on your jardesc file and your JAR file will be ready in a blink.