A. Sidiq Purnomo

Universitas Mercu Buana Yogyakarta

You are here: » Creating an Executable Java (*.exe) File in NetBeans (7.4 or 8.0 or latest version)

Creating an Executable Java (*.exe) File in NetBeans (7.4 or 8.0 or latest version)

1. Requirement

To follow this tutorial, you need the following software and resources.

  1. JDK (Java Development Kit)
    1. Min Version : 7 update 25 (or more recent) or 8
    2. Download : http://www.oracle.com/technetwork/java/javase/downloads/index.html
    3. Installation Instructions :
      1. Installasi Dan Konfigurasi Java (Jdk dan Jre) Format (*.tar.gz) My OS / Ubuntu Linux
      2. Installasi dan konfigurasi Java (JDK & JRE) di Ubuntu dan Microsoft Windows
  2. Netbeans IDE
    1. Min Version : 7.4
    2. Download : http://netbeans.org/downloads/
  3. Inno Setup
    1. Min Version : 5.5 or more recent
    2. Download : http://www.jrsoftware.org/isdl.php
  4. WiX
    1. Min Version : 7 or more recent
    2. Download : http://wix.codeplex.com/releases/view/99514

2. Installing and Adding Required Tools to the Path

To use the IDE’s support for native packaging, the following additional tools need to be installed:

2.1 Inno Setup

  1. Download Inno Setup (Ex : innosetup-5.5.9.exe)
  2. Double-click the file to launch the installer
  3. Accept the Inno Setup license agreement and click Next
  4. Follow the instructions in the install wizard for installing Inno Setup
  5. Add Inno Setup to the system Path variable:
    1. Go to start menu -> Type -> System
    2. Select the Advanced tab and click the Environment Variables button

    1. In the System Variables pane, double-click the Path variable
    2. In the Edit System Variable dialog box

    1. To check if the installed tool is in the Path, open the Command Prompt window and type iscc.exe
    2. You should see the Command Prompt window :

2.2 WiX

  1. Download Wix (Ex : Wix37.exe)
  2. Double-click the file to launch the installer
  3. Accept the Wix license agreement and click Next
  4. Follow the instructions in the install wizard for installing Wix
  5. Add WiX to the system Path variable:
    1. Go to start menu -> Type -> System
    2. Select the Advanced tab and click the Environment Variables button

    1. In the System Variables pane, double-click the Path variable
    2. In the Edit System Variable dialog box

    1. To check if the installed tool is in the Path, open the Command Prompt window and type candle.exe
    2. You should see the the Command Prompt window :

3. Native Packaging in Java SE Projects

3.1 Creating Project

  1. Open Netbeans (Go to start menu -> Programming -> Netbeans)

  1. Click the File menu and select New Project…

  1. Choose :
    1. Java in the Categories list
    2. Java Application in the Projects list

    Then click Next.

  1. In the Name and Location panel,
    1. Type “Project_5” in the Project Name Text Field to change Project Name, or leave the default values for Project Name.
    2. Click Browse button in the Project Location fields to change project location à Navigate to save project directory (ex: D:\DnD_Home\Program\20161\Java_Test\Netbeans\Project_5\), or leave the default values for the Project Location fields.

  1. Click Finish.
  1. After we click finish we get a desktop application with some code and windows.

  1. Click the Run button in the tool bar or choose menu Run à Run Main Project to see what is displayed when we Run the application with the default code.

  1. The application should launch and display on your machine.

3.2 Enabling Native Packaging for the Project

The native packaging actions are disabled in the IDE by default.

  1. Right-click the Project_5 project in the Projects window, to check the actions available for the created Java SE project in the IDE: there are no package related actions in the project’s context menu.
  2. To enable native packaging actions for the project:
    1. Right-click the project node in the Projects window and select Properties from the context menu.

    1. In the Project Properties dialog box, choose the Deployment category and select the Enable Native Packaging Actions in Project Menu option.

    1. Click OK.
      A Package as command is added to the project’s context menu. You should see “Packages as” in the context menu.

3.3 Building an Application

Clean and build your project:

  1. Choose Run -> Clean and Build Project from the main menu.

  1. A dist folder that contains a jar file is created in the project folder.
  2. You should see in the Output window.

  1. To check a jar file, click the Files window and navigate to your project (ex : Project_5) -> dist

3.4 Making an EXE Installer

The application can now be packaged in an installer for Windows. To build an EXE installer :

  1. Right-click the Project_5 project and choose Package as à EXE Installer from the context menu.

  1. You should see in the Output window.

  1. To check a Exe file, click the Files window and navigate to your project (ex : Project_5) -> dist -> bundles

4. Verifying the Installable Applications

When the Project_5-1.0.exe installers are done, you need to check which directory the Project_5 applications are installed natively into.

To check the installers:

  1. Browse to the installer file (Project_5-1.0.exe) on your hard drive -> Double-click to run the installer.

  1. Or right click Project_5-1.0.exe from the context menu -> choose Open in System.

  1. Follow the instructions in the install wizard for installing Project_5

  1. Both the applications should be installed into the C:\Users\<username>\AppData\Local\ directory and be available in the Start menu.

  1. Launch Application

 

PDF Download : Creating an Executable Java File in NetBeans IDE (7.4 or 8.0 or latest version)

Print Friendly, PDF & Email
Posted by 0 Responses
 

Free Email Newsletter

Stay Updates with this Blog. Get Free email newsletter updates..

And then confirm your email subcription

   

No Comment to “Creating an Executable Java (*.exe) File in NetBeans (7.4 or 8.0 or latest version)”

  1. No Comment yet. Be the first to comment...
Leave your comment here:

Secure * Time limit is exhausted. Please reload the CAPTCHA.

Jan
7
2017