Installers for Windows, Linux and MacOS

Windows

One of the best free options:

Example of a building script:

[Setup]
AppName=AWTexample
AppVersion=1.0
DefaultDirName={pf}\AWTexample
DefaultGroupName=AWTexample
UninstallDisplayIcon={app}\AWTexample.jar
Compression=lzma2
SolidCompression=yes
OutputDir=setup

[Files]
Source: "AWTexample.jar"; DestDir: "{app}"
Source: "icon.ico"; DestDir: "{app}"
Source: "README.txt"; DestDir: "{app}"; Flags: isreadme

[Icons]
Name: "{group}\AWTexample"; Filename: "{app}\AWTexample.jar"

Example: InnoSetup project application

Linux

Debian and Ubuntu

http://ubuntuforums.org/showthread.php?t=910717

Decide on the name of your package. Standard debian notation is all lowercase in the following format:

<project>_<major version>.<minor version>-<package revision>

For example, you could name your first package as helloworld_1.0-1

Create a directory to make your package in. The name should be the same as the package name.

mkdir helloworld_1.0-1

Pretend that the packaging directory is actually the root of the file system. Put the files of your program where they would be installed to on a system. For example:

mkdir -p helloworld_1.0-1/usr/bin
cp helloworld helloworld_1.0-1/usr/bin

Now create a special metadata file with which the package manager will install your program:

mkdir helloworld_1.0-1/DEBIAN
vim helloworld_1.0-1/DEBIAN/control

Put something like this in that file:

Package: helloworld
Version: 1.0-1
Section: base
Priority: optional
Architecture: i386
Depends: libsomethingorrather (>= 1.2.13), anotherDependency (>= 1.2.6)
Maintainer: Your Name <you@email.com>
Description: Hello World
 When you need some sunshine, just run this
 small program!

 (the space before each line in the description is important)

Now you just need to build the package:

dpkg-deb --build helloworld_1.0-1

To test package for errors and warnings:

lintian -c helloworld_1.0-1.deb

RedHat and Fedora

http://www.rpm.org/max-rpm/ch-rpm-build.html
https://fedoraproject.org/wiki/How_to_create_an_RPM_package

To create the directory structure to build packages, issue:

rpmdev-setuptree

It will create a folder called rpmbuild in your home. It will contain the following folders:

  • SOURCES: contains the original sources, patches, and icon files
  • SPECS: contains the spec files used to control the build process
  • BUILD: the directory in which the sources are unpacked, and the software is built
  • RPMS: contains the binary package files created by the build process
  • SRPMS: contains the source package files created by the build process

Example of a SPEC file (for example, create awtexample.spec inside SPECS folder):

Name:     awtexample
Version:  1.0
Release:  1
Summary:  The "Hello World" program in AWT
License:  GPLv3+
URL:      http://www.rigon.tk/documentation/installers-windows-linux-macos
Source:   http://www.rigon.tk/documentation/files/installers-windows-linux-macos/AWTexample.jar

%description
The "Hello World" program, done with all bells and whistles of a proper FOSS 
project, including configuration, build, internationalization, help files, etc.

%changelog
* Thu Jul 07 2011 The Coon of Ty <Ty@coon.org> - 2.8-1
- Initial version of the package

%prep
wget -O $RPM_SOURCE_DIR/AWTexample.jar http://www.rigon.tk/documentation/files/installers-windows-linux-macos/AWTexample.jar
unzip -t $RPM_SOURCE_DIR/AWTexample.jar
cp $RPM_SOURCE_DIR/AWTexample.jar .

%build
echo "#!/bin/bash" > awtexample
echo "java -jar /usr/share/AWTexample/AWTexample.jar" >> awtexample
chmod +x awtexample

%install
mkdir -p %{buildroot}/usr/bin
mkdir -p %{buildroot}/usr/share/awtexample
cp awtexample %{buildroot}/usr/bin/
pwd
cp AWTexample.jar %{buildroot}/usr/share/awtexample/

%files
/usr/bin/awtexample
/usr/share/awtexample/AWTexample.jar

Then, run this command to build the package:

rpmbuild -ba awtexample.spec

ArchLinux

Create a PKGBUILD file:

# Maintainer: Your Name <youremail@domain.com>
pkgname=NAME
pkgver=VERSION
pkgrel=1
pkgdesc=""
arch=()
url=""
license=('GPL')
depends=()
install=$pkgname.install
changelog=
source=($pkgname-$pkgver.tar.gz)
md5sums=() #autofill using updpkgsums

build() {
  cd "$pkgname-$pkgver"

  ./configure --prefix=/usr
  make
}

package() {
  cd "$pkgname-$pkgver"

  make DESTDIR="$pkgdir/" install
}

If you need, you can create a .install file to run specific commands during installation. The possible functions are: pre_install, post_install, pre_upgrade, post_upgrade, pre_remove and post_remove.

Then, run:

makepkg

MacOS

DMG file with application contents. Drag and drop into Application folder.

Very interesting tool to build application bundles, installer packages and DMG images:

It is also good checkout OSX Specific Integrations for Java.