Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Create exe of java project

1. Create JAR file (an executable file of Java Application) of your application by using Netbeans.
Click on Run-->Clean and Build Project. Now we have .jar file which is an executable java file this
file is automatically stored under dist folder. C:\Users\Vishal\Documents\NetBeansProjects\Age
Calulator\dist\ Age_Calulator.jar

2. Close Netbeans and check the jar file by double clicking it whether it is executing properly or
not. Double click on the .jar file generated by Netbeans.
3. Now start install4j.

4. Click on New Project.

5. Open New Project by clicking on Open a new window button.

6. Now fill up with following information


      • Full Name –Name of your setup project for your reference. Your choice.
      • Short Name – This name will be used for your SETUP file. Your choice.
      • Version – Version of your setup. Your choice.
      • Publisher – Optional, you can provide your name here.
      • Publisher URL – Optional, if you have website then mention the URL of website.
Click on blue arrow on right top corner for next screen.

7. In this step, you can specify the version requirements for you application.
      • Minimum version – Enter the minimum JDK version required for executing your
application.
      • Maximum version – Enter the maximum JDK version required for executing your
application. Leave this field blank it is assumed as latest version. This is an optional field.
After filling these 2 fields click on blue arrow on right top corner for next screen.

8. In this step, leave all the setting default and move to next screen.
9. Select the folder where you want to save the setup file, which will generated by install4j. I
stored the setup file in Age Calculator folder on Desktop.

10. In this step, leave all the setting default and move to next screen.
11. In this step, leave all the setting default and move to next screen.
12. In this step, leave all the setting default and move to next screen.
13. Select the 1st option Make all path relative when saving the project file. And click on arrow.

14. This step is very important, here you have to select the files and folders you want to include in
your setup project. Follow the steps as shown in figures –
      a.Click on green plus sign--> Add Files and Directories

      b. Now select the Directory option from the Add Files and Directories window and click on
Next
      c. Select your main .jar file directory. In our case we have
C:\Users\Vishal\Documents\NetBeansProjects\Age Calulator\dist
      d. Then click on Next button and move on 4th frame that is Excluded Files and Directories
(see on right side of the pane).
      e. Here select the files and directories which you don’t want to include in your setup project.
      f. And move up to last frame without making any changes and finally click on OK.
      g. Now here I will add additional 3rd party components which I used in my Age Calculator
project i.e. jCalendar 1.4.jar file.
         Note: You must include all those extra files and folders which you have used in your Java
Application project.
      h. Again Directory option from the Add Files and Directories window and click on Next.
      i. On the first screen select Single File option and move to next window.
      j. Click on the Green PLUS button and then select Browse For File, select your desired file.
Here I will my main Application .jar file i.e. Age Calculator.jar and click on Next and move up to
the last screen of the step and click OK.
You will get a screen similar to this –

      This shows that you successfully included all files and folders you need for the setup file to
install. Move to the next step by clicking on Blue Arrow.
15. This window displays your installation tree structure, How your application will be installed on
hard disk.
16. Now simply move to the Configuration Application Launcher window step by clicking on Blue
Arrow without making any changes in windows which will appear.
17. Select New Launcher by double clicking on the New Launcher Icon.

18. In Select Launcher Type window ->Select Generate Launcher.


19. In this screen you have fill the detail of your application executable file i.e. .exe file.
      a. Select GUI application from Executable type group.
      b. Give the name of your .exe file, I gave Age Calculator, you may give name as per your
choice.
      c. Click on Next

20. Leave blank and click on Next.


21. Here you have to add your .jar files. Click on Green Plus button and you will Define class path
entry window.
22. Select the .jar file you created in Netbeans. And all other .jar files which are used in your
Project. Select the Archive option.
23. Then click on browse button to select Archive files.
24. Select the archive files from the list of files.
25. Repeat step 24 for selecting all required archive files.

      I add my both the Archive files Age_calculator.jar (created by me using Netbeans) and
jcalendar 1-4.jar (an 3rd party jar file I used for jCalendar control).

26. Now add the main class of your application. Click on the browse button of Main Class
27. And select the main class from the list which you want to start from.
      You will get the name of your main executable class in front of Main class.
      Click on Next button and skip all coming screens and finally click on OK button to complete
this step.
      After clicking on OK button you can see your new launcher, just now you created.

28. Move to Next window


29. Click on Media option by skipping Installer option from Left side of the pane. This step will
give you the actual setup file which you can distribute to your friends.

29. Double on New media file.


31. In create Media File window, select Windows from Installer type: and click on Next button.
32. Give the name of the setup file and installation directory where you want to install your
application by default. And click on Next button.

Now go to Bundle a JRE with your application by selecting 6. Bundle JRE option from left pane
of window. This is very important to understand here you can include the JRE on which your
application was developed and can run perfectly.
My application is developed on JRE 1.7.0_9 so I should include this, because many may not
have this JRE installed in their PC.
33. Select the Bundle the following JRE: option and choose your JRE from the list of JREs.
34. Next Select the option Static Bundle (distribute with media file).
35. Select Install as a shared JRE.
36. Click on Finish button. And finally click on OK button. And move to the next window by
clicking on Blue Arrow.

 Note: If you don’t have distributable JRE package then you can download at this time as per
your requirement by clicking Download JREs button
37. Finally you reached to the final and last step. Click on Start Build Button. You will get a
message if you are using evaluation version of install4j, else it will start building the setup as per
your settings.
38. If everything is OK then you may get the output as shown in figure.
After the successful build operation your setup file is store under the folder your selected in step
39. Double click on your setup file. Your installation begins with a message of evaluation version
and you can find the installed application on c:\ drive.
Now you can run you java application from start menu.

You might also like