Hello beautiful faces! In this article we’re talking about how you can create an executable jar using Launch4J.
We suppose that you already have written a piece of code in java and you want to make it executable. But what is an executable? Well that’s simple, think of it as a program that can run outside of Eclipse IDE just like all other programs that you already installed on your PC. Basically, at the end of this you will have an application with your favorite icon on your desktop that you can double click to open it anytime you want, thanks to Launch4J. Lets jump right in!
First you have to download Launch4J. Thats a free software that you can get it from here.
Click on download button and the rest is pretty simple.
Jump into Eclipse IDE, open your main class of your java application and click File -> Export:
Click Java -> Runnable Jar File and then Hit Next
After that you have to be careful to select the main class of your project and select an export destination. Click Finish.
On your destination folder you should see the file. Now you have to open Launch4J. After that click on Output File and save it on your preferred destination. It is very important to add .exe after naming!!! Click Save.
Click on Jar. Select the file that you exported earlier and click Open.
You can also set an icon with Launch4J but first you have to download one and it has to be .ico format. Get your favorite from here, for free! Remember, .ico!!! All you have to do is click Icon and select it. Click Open.
Next move to JRE tab and set Min JRE Version to 1.6. Its important! Lastly click Build wrapper (see arrow nr. 3). It will ask you to save some file, just name it and save it and delete it later because it is useless.
And finally you have your beautiful .exe application on your output folder with your favorite icon!!!
Also you can learn how to create setups for your application that you just created on this article.
Stay tuned for more!