<p>Java is one of my programming languages of choice.  I always run into the problem though of distributing my application to end-users.</p>

<p>Giving a user a JAR is not always as user friendly as I would like and using Java WebStart requires that I maintain a web server.</p>

<p>What's the best way to distribute a Java application?  What if the Java application needs to install artifacts to the user's computer?  Are there any good Java installation/packaging systems out there?</p>

[{'answer_id': 80128, 'author': 'jjnguy', 'author_id': 2598, 'author_profile': 'https://Stackoverflow.com/users/2598', 'pm_score': 1, 'selected': False, 'text': "<p>For simple Java apps I like to use Jar's.  It is very simple to distribute one file that a user can just click on (Windows), or</p>\n\n<pre><code>java -jar jarname.jar\n</code></pre>\n\n<p>IMHO, jar is the way to go when simplicity is a main requirement.</p>\n"}, {'answer_id': 80129, 'author': 'zurk', 'author_id': 14907, 'author_profile': 'https://Stackoverflow.com/users/14907', 'pm_score': 2, 'selected': False, 'text': '<p>executable files are best but they are platform limited i.e. use gcj : <a href="http://gcc.gnu.org/java/" rel="nofollow noreferrer">http://gcc.gnu.org/java/</a> for linux to produce executables and use launch4j : <a href="http://launch4j.sourceforge.net/" rel="nofollow noreferrer">http://launch4j.sourceforge.net/</a> to produce windows executables.\nTo package on linux you can use any rpm or deb packager. For win32 try <a href="http://en.wikipedia.org/wiki/Nullsoft_Scriptable_Install_System" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/Nullsoft_Scriptable_Install_System</a> </p>\n'}, {'answer_id': 80147, 'author': 'qualidafial', 'author_id': 13253, 'author_profile': 'https://Stackoverflow.com/users/13253', 'pm_score': 0, 'selected': False, 'text': '<p>The best answer depends on the platform.  For deployment on Windows, I have had good results using a combination of <a href="http://one-jar.sourceforge.net/" rel="nofollow noreferrer">one-jar</a> and <a href="http://launch4j.sourceforge.net/" rel="nofollow noreferrer">launch4j</a>.  It did take a little while to set up my build environment properly (ant scripts, mostly) but now it\'s fairly painless.</p>\n'}, {'answer_id': 80157, 'author': 'Ry4an Brase', 'author_id': 8992, 'author_profile': 'https://Stackoverflow.com/users/8992', 'pm_score': 2, 'selected': False, 'text': "<p>If it's a real GUI-having end user application you should ignore the lanaguage in which you wrote the program (Java) and use a native installer for each of your chosen platforms.  Mac folks want a .dmg and on windows a .msi or a .exe installer is the way to go.  On Windows I prefer NSIS from NullSoft only because it's less objectionable than InstallShield or InstallAnywhere.  On OSX you can count on the JVM already being there.  On Windows you'll need to check and install it for them if necessary.  Linux people won't run Java GUI applications, and the few that will, know what to do with an executable .jar.</p>\n"}, {'answer_id': 80521, 'author': 'Petr Macek', 'author_id': 15045, 'author_profile': 'https://Stackoverflow.com/users/15045', 'pm_score': 0, 'selected': False, 'text': '<p>Well from my point of view the superior distribution mechanism is to use something like <a href="http://en.wikipedia.org/wiki/ClickOnce" rel="nofollow noreferrer">ClickOnce</a>, or <a href="http://en.wikipedia.org/wiki/Webstart" rel="nofollow noreferrer">WebStart</a> technology. You just deploy the version to the server and it gets automatically to the clients when the version is released. \nAlso the Eclipse RCP platform contains UpdateManager that does what WebStart do, but also much more.</p>\n\n<p>Since I am using Maven2 for building, the deployment is just a piece of cake: copy the built jar to the location on the server, update the jnlp file if needed and you are done.</p>\n'}, {'answer_id': 80595, 'author': 'rustyshelf', 'author_id': 6044, 'author_profile': 'https://Stackoverflow.com/users/6044', 'pm_score': 3, 'selected': False, 'text': '<p><a href="http://www.advancedinstaller.com/" rel="noreferrer">advanced installer</a> makes it easy to package java apps as windows executables, and it\'s quite flexible in the way you can set it up. I\'ve found that for distributing java applications to windows clients, this is the easiest way to go.</p>\n'}, {'answer_id': 80597, 'author': 'Noel Grandin', 'author_id': 6591, 'author_profile': 'https://Stackoverflow.com/users/6591', 'pm_score': 8, 'selected': True, 'text': '<p>There are a variety of solutions, depending on your distribution requirements.</p>\n\n<ol>\n<li><p>Just use a jar. This assumes that the user has the the correct java version installed, otherwise the user will get "class-file format version" exceptions. This is fine for internal distribution inside a company.</p></li>\n<li><p>Use launch4j and an installer like NSIS. This gives you a lot more control, although the user can still do stupid stuff like un-installing the java runtime. This is probably the most popular approach, and what I currently use.</p></li>\n<li><p>Use Webstart. This also assumes that the user has the correct java version installed, but it\'s a lot easier to get going. My experience is that this is fine for tightly controlled intranet environments, but becomes a pain with larger deployments because it has some many weird failures. It may get better with the new plug-in technology in Java 1.7.</p></li>\n<li><p>Use a native-code compiler like Excelsior JET and distribute as a executable, or wrap it up in an installer. Expensive, and it generally ties you to a slightly older version of java, and there is some pain with dynamic class-loading, but its very effective for large-scale deployment where you need to minimise your support hassles.</p></li>\n</ol>\n'}, {'answer_id': 80910, 'author': 'Mario Ortegón', 'author_id': 2309, 'author_profile': 'https://Stackoverflow.com/users/2309', 'pm_score': 1, 'selected': False, 'text': "<p>I develop eclipse RCP applications.  Normally to start an eclipse application an executable launcher is included.  I include the java virtual machine inside the application folder in a /jre sub directory to ensure that the right java version will be used.</p>\n\n<p>Then we package with Inno Setup for installation on the user's machine.</p>\n"}, {'answer_id': 81010, 'author': 'Rejeev Divakaran', 'author_id': 10980, 'author_profile': 'https://Stackoverflow.com/users/10980', 'pm_score': -1, 'selected': False, 'text': '<p>I would zip the jar file along with other dependent jars, configuration files and documentation along with a run.bat/run.sh. End user should be able unzip it to any location and edit the run.bat if required (It should run without editing in most of the cases).\nAn installer may be useful if you want to create entries in start menu, desktop, system tray etc.</p>\n\n<p>As a user I prefer unzip and run kind of installation (no start menu entries please). However People outside IT industry may have different preferences. So if the application is largely targeted for developers zip-run.bat route and applications for general public may be installed using a installer.</p>\n'}, {'answer_id': 101628, 'author': 'coobird', 'author_id': 17172, 'author_profile': 'https://Stackoverflow.com/users/17172', 'pm_score': 2, 'selected': False, 'text': '<p>Although I haven\'t used <a href="http://nsis.sourceforge.net/" rel="nofollow noreferrer" title="NSIS">NSIS</a> (Nullsoft Scriptable Installer System) myself, there are install scripts that will check whether or not the required JRE is installed on the target system.</p>\n\n<p>Many sample scripts are available from the <a href="http://nsis.sourceforge.net/Category:Code_Examples" rel="nofollow noreferrer" title="Code Examples">Code Examples</a> and <a href="http://nsis.sourceforge.net/Category:Real_World_Installers" rel="nofollow noreferrer" title="Real World Installers">Real World Installers</a> pages, such as:</p>\n\n<ul>\n<li><a href="http://nsis.sourceforge.net/Java_Launcher_with_automatic_JRE_installation" rel="nofollow noreferrer" title="Java Launcher with automatic JRE installation">Java Launcher with automatic JRE installation</a></li>\n<li><a href="http://nsis.sourceforge.net/Simple_Java_Runtime_Download_Script" rel="nofollow noreferrer" title="Simple Java Runtime Download Script">Simple Java Runtime Download Script</a></li>\n</ul>\n\n<p>(Please note that I haven\'t actually used any of the scripts, so please don\'t take it as an endorsement.)</p>\n'}, {'answer_id': 111942, 'author': 'stian', 'author_id': 17542, 'author_profile': 'https://Stackoverflow.com/users/17542', 'pm_score': 3, 'selected': False, 'text': '<p><a href="http://jsmooth.sourceforge.net/" rel="noreferrer">JSmooth</a> is a simple program that takes your jar and wraps it up in a standard windows executable file. It comes with a simple GUI that allows you to configure the required JVM, bundle it with the application or provide an option to download it if it\'s not already installed. You can send the exe file as is or zip it with possible dependencies (or let the program download the extra dependencies from the net on startup). It\'s also free, as in beer and speech, which may (or may not) be a good thing.</p>\n'}, {'answer_id': 126935, 'author': 'Tom', 'author_id': 20979, 'author_profile': 'https://Stackoverflow.com/users/20979', 'pm_score': 0, 'selected': False, 'text': '<p>installanywhere is good but expensive one - i have not found (as) good free one</p>\n'}, {'answer_id': 142140, 'author': 'David Carlson', 'author_id': 4901, 'author_profile': 'https://Stackoverflow.com/users/4901', 'pm_score': 2, 'selected': False, 'text': '<p>I needed a way to package my project and its dependencies into a single jar file.</p>\n\n<p>I found what I needed using the Maven2 Assembly plugin: <a href="http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies" rel="nofollow noreferrer">Maven2 Assembly plugin</a></p>\n\n<p>This appears to duplicate the functionality of <a href="http://one-jar.sourceforge.net/" rel="nofollow noreferrer">one-jar</a>, but requires no additional configuration to get it going.</p>\n'}, {'answer_id': 455034, 'author': 'Daniel Lopez', 'author_id': 56395, 'author_profile': 'https://Stackoverflow.com/users/56395', 'pm_score': 2, 'selected': False, 'text': '<p>It depends on how sophisticated your target users are. In most cases you want to isolate them from the fact that you are running a Java-based app. Give them with a native installer that does the right thing (create start menu entries, launchers, register with add/remove programs, etc.) and already bundles a Java runtime (so the user does not need to know or care about it). I would like to suggest our cross platform installation tool, <a href="http://bitrock.com" rel="nofollow noreferrer">BitRock InstallBuilder</a>. Although it is not Java-based, it is commonly used to package Java applications. It can be easily integrated with Ant and you can build Windows installers from Unix/Linux/Mac and the other way around. Because the generated installers are native, they do not require a self-extraction step or a JRE to be already present in the target system, which means smaller installers and saves you some headaches. I also would like to mention we have free licenses for open source projects</p>\n'}, {'answer_id': 844999, 'author': 'Jonik', 'author_id': 56285, 'author_profile': 'https://Stackoverflow.com/users/56285', 'pm_score': 1, 'selected': False, 'text': '<blockquote>\n  <p>What\'s the best way to distribute a\n  Java application? What if the Java\n  application needs to install artifacts\n  to the user\'s computer? Are there any\n  good Java installation/packaging\n  systems out there?</p>\n</blockquote>\n\n<p>In my experience (from <a href="https://stackoverflow.com/questions/759855/what-are-good-installanywhere-replacements-for-installing-a-java-ee-application/786307#786307">evaluating a number of options</a>), <a href="http://www.ej-technologies.com/products/install4j/overview.html" rel="nofollow noreferrer">install4j</a> is a good solution. It creates native installers for any platform, and is specifically geared towards installing Java apps. For details, see "<a href="http://www.ej-technologies.com/products/install4j/features.html" rel="nofollow noreferrer">Features</a>" on its website.</p>\n\n<p>install4j is a commercial tool, though. Especially if your needs are relatively simple (just distribute an application and install some artifacts), many other good options exist, including free ones (like <a href="http://izpack.org/" rel="nofollow noreferrer">izPack</a> or the already mentioned <a href="http://launch4j.sourceforge.net/" rel="nofollow noreferrer">Lauch4j</a>). But you asked for the <em>best</em> way, and to my current knowledge install4j is the one, especially for distributing larger or more complicated Java (EE) apps.</p>\n'}]
['https://Stackoverflow.com/questions/80105', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/14204/']