Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    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> <h2>Project Copies of launch4j and NSIS</h2> <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> <h2>Script Files</h2> <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> <pre><code>&lt;launch4jConfig&gt; &lt;dontWrapJar&gt;true&lt;/dontWrapJar&gt; &lt;headerType&gt;gui&lt;/headerType&gt; &lt;jar&gt;rpgam.jar&lt;/jar&gt; &lt;outfile&gt;rpgam.exe&lt;/outfile&gt; &lt;errTitle&gt;&lt;/errTitle&gt; &lt;cmdLine&gt;&lt;/cmdLine&gt; &lt;chdir&gt;.&lt;/chdir&gt; &lt;priority&gt;normal&lt;/priority&gt; &lt;downloadUrl&gt;http://www.rpgaudiomixer.com/&lt;/downloadUrl&gt; &lt;supportUrl&gt;&lt;/supportUrl&gt; &lt;customProcName&gt;false&lt;/customProcName&gt; &lt;stayAlive&gt;false&lt;/stayAlive&gt; &lt;manifest&gt;&lt;/manifest&gt; &lt;icon&gt;&lt;/icon&gt; &lt;jre&gt; &lt;path&gt;&lt;/path&gt; &lt;minVersion&gt;1.5.0&lt;/minVersion&gt; &lt;maxVersion&gt;&lt;/maxVersion&gt; &lt;jdkPreference&gt;preferJre&lt;/jdkPreference&gt; &lt;/jre&gt; &lt;splash&gt; &lt;file&gt;..\images\splash.bmp&lt;/file&gt; &lt;waitForWindow&gt;true&lt;/waitForWindow&gt; &lt;timeout&gt;60&lt;/timeout&gt; &lt;timeoutErr&gt;true&lt;/timeoutErr&gt; &lt;/splash&gt; &lt;/launch4jConfig&gt; </code></pre> <p>And then there's the NSIS script rpgam-setup.nsis. It can take a VERSION argument to help name the file.</p> <pre><code>; The name of the installer Name "RPG Audio Mixer" !ifndef VERSION !define VERSION A.B.C !endif ; The file to write outfile "..\dist\installers\windows\rpgam-${VERSION}.exe" ; The default installation directory InstallDir "$PROGRAMFILES\RPG Audio Mixer" ; Registry key to check for directory (so if you install again, it will ; overwrite the old one automatically) InstallDirRegKey HKLM "Software\RPG_Audio_Mixer" "Install_Dir" # create a default section. section "RPG Audio Mixer" SectionIn RO ; Set output path to the installation directory. SetOutPath $INSTDIR File /r "..\dist\layout\windows\" ; Write the installation path into the registry WriteRegStr HKLM SOFTWARE\RPG_Audio_Mixer "Install_Dir" "$INSTDIR" ; Write the uninstall keys for Windows WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RPGAudioMixer" "DisplayName" "RPG Audio Mixer" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RPGAudioMixer" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RPGAudioMixer" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RPGAudioMixer" "NoRepair" 1 WriteUninstaller "uninstall.exe" ; read the value from the registry into the $0 register ;readRegStr $0 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" CurrentVersion ; print the results in a popup message box ;messageBox MB_OK "version: $0" sectionEnd Section "Start Menu Shortcuts" CreateDirectory "$SMPROGRAMS\RPG Audio Mixer" CreateShortCut "$SMPROGRAMS\RPG Audio Mixer\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 CreateShortCut "$SMPROGRAMS\RPG AUdio Mixer\RPG Audio Mixer.lnk" "$INSTDIR\rpgam.exe" "" "$INSTDIR\rpgam.exe" 0 SectionEnd Section "Uninstall" ; Remove registry keys DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\RPGAudioMixer" DeleteRegKey HKLM SOFTWARE\RPG_Audio_Mixer ; Remove files and uninstaller Delete $INSTDIR\rpgam.exe Delete $INSTDIR\uninstall.exe ; Remove shortcuts, if any Delete "$SMPROGRAMS\RPG Audio Mixer\*.*" ; Remove directories used RMDir "$SMPROGRAMS\RPG Audio Mixer" RMDir "$INSTDIR" SectionEnd </code></pre> <h2>Ant Integration</h2> <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> <pre><code>&lt;property name="launch4j.dir" location="vendor/launch4j" /&gt; &lt;taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="${launch4j.dir}/launch4j.jar:${launch4j.dir}/lib/xstream.jar" /&gt; </code></pre> <p>I then have a simple target for creating the wrapper executable:</p> <pre><code>&lt;target name="executable-windows" depends="jar" description="Create Windows executable (EXE)"&gt; &lt;launch4j configFile="scripts/launch4j.xml" outfile="${exeFile}" /&gt; &lt;/target&gt; </code></pre> <p>And another target for making the installer:</p> <pre><code>&lt;target name="installer-windows" depends="executable-windows" description="Create the installer for Windows (EXE)"&gt; &lt;!-- Lay out files needed for building the installer --&gt; &lt;mkdir dir="${windowsLayoutDirectory}" /&gt; &lt;copy file="${jarFile}" todir="${windowsLayoutDirectory}" /&gt; &lt;copy todir="${windowsLayoutDirectory}/lib"&gt; &lt;fileset dir="${libraryDirectory}" /&gt; &lt;fileset dir="${windowsLibraryDirectory}" /&gt; &lt;/copy&gt; &lt;copy todir="${windowsLayoutDirectory}/icons"&gt; &lt;fileset dir="${iconsDirectory}" /&gt; &lt;/copy&gt; &lt;copy todir="${windowsLayoutDirectory}" file="${exeFile}" /&gt; &lt;mkdir dir="${windowsInstallerDirectory}" /&gt; &lt;!-- Build the installer using NSIS --&gt; &lt;exec executable="vendor/nsis/makensis.exe"&gt; &lt;arg value="/DVERSION=${version}" /&gt; &lt;arg value="scripts/rpgam-setup.nsi" /&gt; &lt;/exec&gt; &lt;/target&gt; </code></pre> <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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload