<p>I am writing an application in Java for the desktop using the Eclipse SWT library for GUI rendering.  I think SWT helps Java get over the biggest hurdle for acceptance on the desktop: namely providing a Java application with a consistent, responsive interface that looks like that belonging to any other app on your desktop.  However, I feel that packaging an application is still an issue.  </p>

<p>OS X natively provides an easy mechanism for wrapping Java apps in native application bundles, but producing an app for Windows/Linux that doesn't require the user to run an ugly batch file or click on a .jar is still a hassle.  Possibly that's not such an issue on Linux, where the user is likely to be a little more tech-savvy, but on Windows I'd like to have a regular .exe for him/her to run.</p>

<p>Has anyone had any experience with any of the .exe generation tools for Java that are out there?  I've tried JSmooth but had various issues with it.  Is there a better solution before I crack out Visual Studio and roll my own?</p>

<p><strong>Edit:</strong>  I should perhaps mention that I am unable to spend a lot of money on a commercial solution.</p>

[{'answer_id': 7747, 'author': 'basszero', 'author_id': 287, 'author_profile': 'https://Stackoverflow.com/users/287', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://www.ej-technologies.com/products/install4j/overview.html" rel="nofollow noreferrer">Install4J</a>. Not free, but worth it. Give the trial a shot</p>\n'}, {'answer_id': 7759, 'author': 'basszero', 'author_id': 287, 'author_profile': 'https://Stackoverflow.com/users/287', 'pm_score': 0, 'selected': False, 'text': "<p>I went through the same and found that all of the free options weren't very good. Looks like you'll be writing your own. I'd be interested to see if someone has a free/cheap option that works</p>\n"}, {'answer_id': 7796, 'author': 'Jason Day', 'author_id': 737, 'author_profile': 'https://Stackoverflow.com/users/737', 'pm_score': 2, 'selected': False, 'text': '<p>Have you thought about <a href="http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp" rel="nofollow noreferrer">Java Web Start</a>?  <a href="http://www.ibm.com/developerworks/opensource/library/os-jws/" rel="nofollow noreferrer">Here</a> is a tutorial specifically for deploying an SWT application with Java Web Start.</p>\n'}, {'answer_id': 8598, 'author': 'cringe', 'author_id': 834, 'author_profile': 'https://Stackoverflow.com/users/834', 'pm_score': 3, 'selected': False, 'text': '<p>Maybe you should take a look at <a href="http://izpack.org/" rel="nofollow noreferrer">IzPack</a>. I created a very nice installer some years ago and I\'d bet that they are still improving it. It allows the installation of docs, binaries and a clickable link to start the application <em>IIRC</em>.</p>\n'}, {'answer_id': 8602, 'author': 'Derek Park', 'author_id': 872, 'author_profile': 'https://Stackoverflow.com/users/872', 'pm_score': 2, 'selected': False, 'text': '<p>Have you considered writing a small program in C/C++ that just calls <a href="http://msdn.microsoft.com/en-us/library/ms682425.aspx" rel="nofollow noreferrer"><code>CreateProcess</code></a> to start up the java VM with the jar (or class) file?</p>\n\n<p>You could get <a href="http://www.microsoft.com/express/vc/" rel="nofollow noreferrer">Visual C++ Express</a> and put together the startup program pretty easily.  This would make it easy to add a friendly icon as well.</p>\n'}, {'answer_id': 8620, 'author': 'alexmcchessers', 'author_id': 998, 'author_profile': 'https://Stackoverflow.com/users/998', 'pm_score': 0, 'selected': False, 'text': "<p>Another option I was considering: rather than writing a native launcher from scratch, Eclipse comes with the source code for its own launcher, and this could perhaps be repurposed for my app.</p>\n\n<p>It's a shame that Sun never included anything similar in the JDK.</p>\n"}, {'answer_id': 26942, 'author': 'Johannes K. Lehnert', 'author_id': 2367, 'author_profile': 'https://Stackoverflow.com/users/2367', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve used the free <a href="http://launch4j.sourceforge.net/" rel="nofollow noreferrer">Launch4J</a> to create a custom launcher for my Java programs on Windows. Combined with the free <a href="http://nsis.sourceforge.net/Main_Page" rel="nofollow noreferrer">NSIS Installer</a> you can build a nice package for your Windows users.</p>\n\n<p><strong>Edit:</strong> Did not see that you use SWT. Don\'t know if it works with SWT as well, because I used only Swing in my apps.</p>\n'}, {'answer_id': 74597, 'author': 'pauxu', 'author_id': 13014, 'author_profile': 'https://Stackoverflow.com/users/13014', 'pm_score': 3, 'selected': False, 'text': '<p>In my company we use <a href="http://launch4j.sourceforge.net/" rel="noreferrer">Launch4J</a> to create the exe file, and <a href="http://nsis.sourceforge.net/" rel="noreferrer">NSIS</a> to create the installer, with SWT applications. </p>\n\n<p>We have used it for years in several commercial applications and the pair works fine.</p>\n'}, {'answer_id': 75908, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Another vote for Launch4J, just wrote an ant task this morning to integrate with one of my projects.  Seems to work really well</p>\n'}, {'answer_id': 76548, 'author': 'Heath Borders', 'author_id': 9636, 'author_profile': 'https://Stackoverflow.com/users/9636', 'pm_score': 2, 'selected': False, 'text': '<p>Consider converting your application to <a href="http://wiki.eclipse.org/index.php/Rich_Client_Platform" rel="nofollow noreferrer">Eclipse RCP</a>.  It is written in <a href="http://eclipse.org/swt" rel="nofollow noreferrer">SWT</a>, and the Eclipse IDE contains packaging tools that generate executables for all major platforms.  For windows, it can generate a zip or a folder containing your code.  For a common installation experience, I\'d using NSIS.  There is actually a <a href="http://wiki.eclipse.org/Eclipse_RCP_Installer/Packages_Generator" rel="nofollow noreferrer">packages generator</a> project at eclipse to create common installers for all platforms eclipse supports.</p>\n'}, {'answer_id': 149971, 'author': 'Brian Kelly', 'author_id': 8252, 'author_profile': 'https://Stackoverflow.com/users/8252', 'pm_score': 6, 'selected': True, 'text': '<p>To follow up on pauxu\'s answer, I\'m using launch4j and NSIS on a project of mine and thought it would be helpful to show just how I\'m using them.  Here\'s what I\'m doing for Windows.  BTW, I\'m creating .app and .dmg for Mac, but haven\'t figured out what to do for Linux yet.</p>\n\n<h2>Project Copies of launch4j and NSIS</h2>\n\n<p>In my project I have a "vendor" directory and underneath it I have a directory for "launch4j" and "nsis".  Within each is a copy of the install for each application.  I find it easier to have a copy local to the project rather than forcing others to install both products and set up some kind of environment variable to point to each.</p>\n\n<h2>Script Files</h2>\n\n<p>I also have a "scripts" directory in my project that holds various configuration/script files for my project.  First there is the launch4j.xml file:</p>\n\n<pre><code>&lt;launch4jConfig&gt;\n  &lt;dontWrapJar&gt;true&lt;/dontWrapJar&gt;\n  &lt;headerType&gt;gui&lt;/headerType&gt;\n  &lt;jar&gt;rpgam.jar&lt;/jar&gt;\n  &lt;outfile&gt;rpgam.exe&lt;/outfile&gt;\n  &lt;errTitle&gt;&lt;/errTitle&gt;\n  &lt;cmdLine&gt;&lt;/cmdLine&gt;\n  &lt;chdir&gt;.&lt;/chdir&gt;\n  &lt;priority&gt;normal&lt;/priority&gt;\n  &lt;downloadUrl&gt;http://www.rpgaudiomixer.com/&lt;/downloadUrl&gt;\n  &lt;supportUrl&gt;&lt;/supportUrl&gt;\n  &lt;customProcName&gt;false&lt;/customProcName&gt;\n  &lt;stayAlive&gt;false&lt;/stayAlive&gt;\n  &lt;manifest&gt;&lt;/manifest&gt;\n  &lt;icon&gt;&lt;/icon&gt;\n  &lt;jre&gt;\n    &lt;path&gt;&lt;/path&gt;\n    &lt;minVersion&gt;1.5.0&lt;/minVersion&gt;\n    &lt;maxVersion&gt;&lt;/maxVersion&gt;\n    &lt;jdkPreference&gt;preferJre&lt;/jdkPreference&gt;\n  &lt;/jre&gt;\n  &lt;splash&gt;\n    &lt;file&gt;..\\images\\splash.bmp&lt;/file&gt;\n    &lt;waitForWindow&gt;true&lt;/waitForWindow&gt;\n    &lt;timeout&gt;60&lt;/timeout&gt;\n    &lt;timeoutErr&gt;true&lt;/timeoutErr&gt;\n  &lt;/splash&gt;\n&lt;/launch4jConfig&gt;\n</code></pre>\n\n<p>And then there\'s the NSIS script rpgam-setup.nsis.  It can take a VERSION argument to help name the file.</p>\n\n<pre><code>; The name of the installer\nName "RPG Audio Mixer"\n\n!ifndef VERSION\n    !define VERSION A.B.C\n!endif\n\n; The file to write\noutfile "..\\dist\\installers\\windows\\rpgam-${VERSION}.exe"\n\n; The default installation directory\nInstallDir "$PROGRAMFILES\\RPG Audio Mixer"\n\n; Registry key to check for directory (so if you install again, it will \n; overwrite the old one automatically)\nInstallDirRegKey HKLM "Software\\RPG_Audio_Mixer" "Install_Dir"\n\n# create a default section.\nsection "RPG Audio Mixer"\n\n    SectionIn RO\n\n    ; Set output path to the installation directory.\n    SetOutPath $INSTDIR\n    File /r "..\\dist\\layout\\windows\\"\n\n    ; Write the installation path into the registry\n    WriteRegStr HKLM SOFTWARE\\RPG_Audio_Mixer "Install_Dir" "$INSTDIR"\n\n    ; Write the uninstall keys for Windows\n    WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\RPGAudioMixer" "DisplayName" "RPG Audio Mixer"\n    WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\RPGAudioMixer" "UninstallString" \'"$INSTDIR\\uninstall.exe"\'\n    WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\RPGAudioMixer" "NoModify" 1\n    WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\RPGAudioMixer" "NoRepair" 1\n    WriteUninstaller "uninstall.exe"\n\n    ; read the value from the registry into the $0 register\n    ;readRegStr $0 HKLM "SOFTWARE\\JavaSoft\\Java Runtime Environment" CurrentVersion\n\n    ; print the results in a popup message box\n    ;messageBox MB_OK "version: $0"\n\nsectionEnd\n\nSection "Start Menu Shortcuts"\n  CreateDirectory "$SMPROGRAMS\\RPG Audio Mixer"\n  CreateShortCut "$SMPROGRAMS\\RPG Audio Mixer\\Uninstall.lnk" "$INSTDIR\\uninstall.exe" "" "$INSTDIR\\uninstall.exe" 0\n  CreateShortCut "$SMPROGRAMS\\RPG AUdio Mixer\\RPG Audio Mixer.lnk" "$INSTDIR\\rpgam.exe" "" "$INSTDIR\\rpgam.exe" 0\nSectionEnd\n\nSection "Uninstall"\n\n    ; Remove registry keys\n    DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\RPGAudioMixer"\n    DeleteRegKey HKLM SOFTWARE\\RPG_Audio_Mixer\n\n    ; Remove files and uninstaller\n    Delete $INSTDIR\\rpgam.exe\n    Delete $INSTDIR\\uninstall.exe\n\n    ; Remove shortcuts, if any\n    Delete "$SMPROGRAMS\\RPG Audio Mixer\\*.*"\n\n    ; Remove directories used\n    RMDir "$SMPROGRAMS\\RPG Audio Mixer"\n    RMDir "$INSTDIR"\n\nSectionEnd\n</code></pre>\n\n<h2>Ant Integration</h2>\n\n<p>I have some targets in my Ant buildfile (build.xml) to handle the above.  First I tel Ant to import launch4j\'s Ant tasks:</p>\n\n<pre><code>&lt;property name="launch4j.dir" location="vendor/launch4j" /&gt;\n&lt;taskdef name="launch4j" \n    classname="net.sf.launch4j.ant.Launch4jTask"\n    classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar" /&gt;\n</code></pre>\n\n<p>I then have a simple target for creating the wrapper executable:</p>\n\n<pre><code>&lt;target name="executable-windows" depends="jar" description="Create Windows executable (EXE)"&gt;\n    &lt;launch4j configFile="scripts/launch4j.xml" outfile="${exeFile}" /&gt;\n&lt;/target&gt;\n</code></pre>\n\n<p>And another target for making the installer:</p>\n\n<pre><code>&lt;target name="installer-windows" depends="executable-windows" description="Create the installer for Windows (EXE)"&gt;\n    &lt;!-- Lay out files needed for building the installer --&gt;\n    &lt;mkdir dir="${windowsLayoutDirectory}" /&gt;\n    &lt;copy file="${jarFile}" todir="${windowsLayoutDirectory}" /&gt;\n    &lt;copy todir="${windowsLayoutDirectory}/lib"&gt;\n        &lt;fileset dir="${libraryDirectory}" /&gt;\n        &lt;fileset dir="${windowsLibraryDirectory}" /&gt;\n    &lt;/copy&gt;\n    &lt;copy todir="${windowsLayoutDirectory}/icons"&gt;\n         &lt;fileset dir="${iconsDirectory}" /&gt;\n    &lt;/copy&gt;\n    &lt;copy todir="${windowsLayoutDirectory}" file="${exeFile}" /&gt;\n\n    &lt;mkdir dir="${windowsInstallerDirectory}" /&gt;\n\n    &lt;!-- Build the installer using NSIS --&gt;\n    &lt;exec executable="vendor/nsis/makensis.exe"&gt;\n        &lt;arg value="/DVERSION=${version}" /&gt;\n        &lt;arg value="scripts/rpgam-setup.nsi" /&gt;\n    &lt;/exec&gt;\n&lt;/target&gt;\n</code></pre>\n\n<p>The top portion of that just copies the necessary files for the installer to a temporary location and the second half executes the script that uses all of it to make the installer.</p>\n'}, {'answer_id': 242507, 'author': 'James Van Huis', 'author_id': 31828, 'author_profile': 'https://Stackoverflow.com/users/31828', 'pm_score': 0, 'selected': False, 'text': '<p>I have used JSmooth in the past, and still have luck with it.  The UI is pretty buggy, but I only use that for building the config file once, and then I build from Ant after that.</p>\n\n<p>What issues are you having with JSmooth?</p>\n'}, {'answer_id': 438536, 'author': 'Thorbjørn Ravn Andersen', 'author_id': 53897, 'author_profile': 'https://Stackoverflow.com/users/53897', 'pm_score': 0, 'selected': False, 'text': '<p>JSMooth has worked very well for us in a production environment, where I first generated a single jar using one-jar (fat jar plugin to eclipse) and then wrapped it with JSmooth.</p>\n\n<p>(Please note that I wanted a no-install distribution of a single file, which could promt for installing the JRE if needed).</p>\n\n<p>It has worked so well that I thought nobody was using it :)</p>\n'}, {'answer_id': 455074, 'author': 'Daniel Lopez', 'author_id': 56395, 'author_profile': 'https://Stackoverflow.com/users/56395', 'pm_score': 0, 'selected': False, 'text': '<p>You may want to try our tool, <a href="http://bitrock.com" rel="nofollow noreferrer">BitRock InstallBuilder</a>. Although it is a native application, a lot of our customers use it to package desktop Java applications. If you bundle the JRE and create launcher, etc. the user does not even need to know they are installing a Java application. It is cross platform, so you can generate installers for both Windows and Mac (and Linux, Solaris, etc.) Like install4j tool mentioned in another post, it is a commercial tool, <em>but</em> we have free licenses for open source projects and special discounts for microISVs / small business, etc. just drop us an email.  Also wanted to emphasize that this is an installer tool, so it will not address your needs if you are looking only for a single file executable.</p>\n'}, {'answer_id': 1214727, 'author': 'Gatorhall', 'author_id': 39527, 'author_profile': 'https://Stackoverflow.com/users/39527', 'pm_score': 0, 'selected': False, 'text': '<p>In my company we use launch4J and NSIS for the windows distribution, and jdeb for the Debian distribution, and Java Web Start for the general operating system. This works quite fine.</p>\n'}, {'answer_id': 9884607, 'author': 'Munim', 'author_id': 981001, 'author_profile': 'https://Stackoverflow.com/users/981001', 'pm_score': 0, 'selected': False, 'text': '<p>Please try <a href="http://www.installjammer.com/" rel="nofollow">InstallJammer</a>.The best one I have used ever. Free and powerful.And sufficient for personal and commercial use.</p>\n'}, {'answer_id': 23582843, 'author': 'Mafro34', 'author_id': 710641, 'author_profile': 'https://Stackoverflow.com/users/710641', 'pm_score': 1, 'selected': False, 'text': '<p>You can now do this through Netbeans! It\'s really easy and works perfectly. Check out <a href="https://netbeans.org/kb/docs/java/native_pkg.html" rel="nofollow">this</a> tutorial on the Netbeans website.</p>\n'}, {'answer_id': 25479992, 'author': 'Richboy', 'author_id': 3691358, 'author_profile': 'https://Stackoverflow.com/users/3691358', 'pm_score': 0, 'selected': False, 'text': "<p>Have you considered Advanced Installer?<br/><br/>\nI have used it severally especially for Windows and Mac. No scripting or Ant required. All GUI. Very simple and understandable. Ain't free but worth every penny.<br/><br/>\n- Lauch as Administrator<br/>\n- File Association<br/>\n- Custom Install Themes + In built Themes<br/>\n- Package with JRE<br/>\n- Install location<br/>\n- Native Splash screen implementation<br/>\n- You can event create services and installation events<br/>\n- Prerequisites<br/>\n- JRE minimum version and maximum version<br/><br/></p>\n\n<p>And a lot more. And don't get it twisted, i have no connections with the dudes...their App is just awesome.</p>\n"}]
['https://Stackoverflow.com/questions/7720', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/998/']