banner



How To Create Exe File In Java Netbeans

From Usarsim

Jump to: navigation, search

Back to Tutorials

Contents

  • 1 How to Create an Executable Java Jar File in NetBeans
    • 1.1 Introduction
    • 1.2 Objectives
    • 1.3 Prerequisites
    • 1.4 Create Jar File
  • 2 FAQ

How to Create an Executable Java Jar File in NetBeans

If you wish to view this tutorial as a PDF, use the link below. This PDF does not have the FAQ section which may help with issues outside of this tutorial.
Executable Java Tutorial PDF

Introduction

This is a method to create executable java jar files when the program was written in the NetBeans IDE.

Objectives

  • Create Jar File

Prerequisites

  • Requires NetBeans and a general knowledge of how to use it.
  • Expects that a program has already been written and simply needs to create an executable file.

Create Jar File

The tool is finished and now the programs are ready to publish to the SVN directory to expand the usability of USARSim. First make sure the program is debugged and ready to be used by others by creating easy to use configuration files so that the code is easily manipulated without opening the source, editing the code, and then going through this process again. Save all files and set the project with the program as the main project. Do this by right clicking the project in the Projects tab and click "Set as Main Project", as shown in figure 1. I will be working with the SoundSensorServer Project throughout this tutorial.

figure 1: Setting the Main Project.


Next go up to the File menu and select Project Properties (Your Project Name). In the new window click on Run in the Categories area. Fill out the text fields with the appropriate information, as shown in figure 2.

figure 2: Setting up the main class.


The Main Class is necessary and all others are optional. If there are any libraries or other jar files that are required to run the program then click on Libraries in the Categories area and add all the appropriate libraries and jar files. Click the ok button and right click on the project over in the project tab and click Clean and Build, as shown in figure 3.

figure 3: Clean and Build the Project.


In the project folder a new folder dist was created with the executable jar file of the program, see figure 4.

figure 4: The new java jar file.


Change the name as you deem necessary, as it will have the name of the project not the individual program. Move it to a new folder in the Tools directory of USARSim and be sure to keep all of the configuration files and any documentation for the individual program together in this new folder.


If you have multiple programs in the same package that must be executable, be sure to remove the jar of the first program to the new folder and change its name before going back to the project properties, selecting run, and changing the Main Class. Otherwise, NetBeans will overwrite the old jar and since the jar file holds the name of the package.


You can either double click this executable jar to run it, or run it in the command line with the command "java –jar filename.jar", where filename is whatever you called the jar file.

FAQ

How To Create Exe File In Java Netbeans

Source: http://usarsim.sourceforge.net/wiki/index.php/Creating_an_Executable_Java_File_in_NetBeans

Posted by: leboeuffroir2002.blogspot.com

0 Response to "How To Create Exe File In Java Netbeans"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel