Pages

Packaging and Deploying Desktop Java Applications

Tuesday, 15 October 2013

Packaging and Deploying Desktop Java Applications

Prerequisites

This tutorial has no prerequisites.
Software or ResourceVersion Required
NetBeans IDEJava SE, Java, or All bundle
Java Development Kit (JDK)version 6 or
version 5

Building the Project and Creating the JAR File

Now that you have your sources ready and your project configured, it is time to build your project.
To build the project:
  • Choose Build > Build Main Project.
When you build your project:
  • build and dist folders are added to your project folder (hereafter referred to as the PROJECT_HOME folder).
  • All of the sources are compiled into .class files, which are placed into the PROJECT_HOME/build folder.
  • A JAR file containing your project is created inside the PROJECT_HOME/dist folder.
  • If you have specified any libraries for the project (in addition to the JDK), a lib folder is created in the dist folder. The libraries are copied intodist/lib.
  • The manifest file in the JAR is updated to include entries that designate main class and any libraries that are on the project's classpath.

To add the JAR file association on Microsoft Windows systems:

  1. Make sure that there is a version of the JRE installed on your system. You should use version 1.4.2 or later. (If you have the JDK installed, you also get the JRE. However, if you are distributing the program to a non-programmer, that person does not necessarily have either the JRE or the JDK.)
    On Windows XP, you can check for installed versions of the JRE by choosing Start > Control Panel > Add or Remove Software.
    If there is not a JRE on the system, you can get one from the Java SE download site.
    If you have a JRE installed on your system but the file association is not working, continue with the steps below.
  2. Choose Start > Control Panel.
  3. Double-click Folder Options.
  4. Select the File Types tab.
  5. In the Registered File Types list, select JAR File.
  6. In the Details section of the dialog box, click Change.
  7. In the Open With dialog box, select Java Platform SE Binary.
  8. Click OK to exit the Open With dialog box.
  9. Click Close to exit the Folder Options dialog box.
If JAR files are associated with the Java Platform SE Binary on your system but double-clicking still does not execute the file JAR file, you might need to specify the -jar option in the file association.
To specify the -jar option in the file association:
  1. Choose Start > Control Panel.
  2. Double-click Folder Options.
  3. Select the File Types tab.
  4. In the Registered File Types list, select JAR File.
  5. In the Details section of the dialog box, click Advanced.
  6. In the Edit File Type dialog box, click Edit.
  7. In the Application Used to Perform Action text field, add the following at the end of the path to the JRE:
     -jar "%1" %*
    Afterwards, the field should contain text similar to the following:
    "C:\Program Files\Java\jre1.6.0_14\bin\javaw.exe" -jar "%1" %*
  8. Click OK to exit the Editing Action for Type dialog box.
  9. Click OK to exit the Edit File Type dialog box.
  10. Click Close to exit the Folder Options dialog box.
For UNIX and Linux systems, the procedure for changing file associations depends on which desktop environment (such as GNOME or KDE) that you are using. Look in your desktop environment's preference settings or consult the documentation for the desktop environment.

No comments:

Post a Comment

 

Blogger news

Blogroll

Most Reading

Tags