1

I want to create my own installer using java, i don't want to use any installer but create one.

I have read about all the other installers such as izpack, install4j, InstallJammer, InstallBuilder etc. I have searched about creating installer but could not find any helpful resource.

Where and how should I start my installer so that it performs all the actions that other installers do such as installation path, zip/unzip, register to the add/remove program panel,uninstall the program when needed etc.

Thanks in advance.

  • Why use an installer at all? all you need to provide is a .jar file – Stultuske Apr 08 '16 at 07:17
  • Don't. Even Jetbrains, creator of Intellij IDEA and other programming tools based on Java is shipping a distribution for Windows, Mac and Linux. They would've created a universal installer if it made sense. – Boris Pavlović Apr 08 '16 at 07:17
  • @CHINMAYBHARDWAJ a simple jar file doesn't have to be installed, it just has to be run. – Stultuske Apr 08 '16 at 07:32
  • @BorisPavlović so what you are suggesting is that I should stick to the available installers only? If that is the case then could you suggest any good installer that i should use. – Chinmay Bhardwaj Apr 08 '16 at 07:34
  • @Stultuske yes, but in my case i want my application to install on the system rather than run directly – Chinmay Bhardwaj Apr 08 '16 at 07:36
  • look at whatever Jetbrains is doing. for Linux you have several packagers depending on the target distribution, RPM, apt-get... – Boris Pavlović Apr 08 '16 at 07:46
  • "could not find any helpful resource" - what problems did you experience? install4j has actions for all the tasks that you mention and creates installers and packages for multiple platforms. – Ingo Kegel Apr 08 '16 at 07:56
  • @IngoKegel "could not find any helpful resource" for creating my own installer. I am not saying that I am having trouble in using any installer. – Chinmay Bhardwaj Apr 08 '16 at 08:06
  • It would be interesting to know what problems you experienced. – Ingo Kegel Apr 08 '16 at 08:11
  • @IngoKegel I am just trying to create an installer using java but could not find a way to start my work on it. – Chinmay Bhardwaj Apr 08 '16 at 08:27
  • Then I would suggest not to pursue that strategy. There is a huge amount of complicated issues to solve. – Ingo Kegel Apr 08 '16 at 08:41
  • @IngoKegel the problem i get using install4j is that it gives class not found exception after the installation process is complete. I created the executable file using the documentation provided on its site. – Chinmay Bhardwaj Apr 08 '16 at 09:47
  • Then you have not correctly set up the classpath of the launcher. Please feel free to contact support@ej-technologies.com to work on this issue. – Ingo Kegel Apr 08 '16 at 09:49
  • JetBrains is a bad example, there the target audience is obviously someone who know how to install Java, which it may not be the case for an another java app. also you may have plenty of resource files that may not make sense to put into a jar. Having Java installers perfectly makes sense. – Yeti Apr 11 '16 at 21:44

1 Answers1

0

First of all, think of whether you really need an installer. As mentioned in the comments, Java applications can be easily distributed as a single JAR (usualy a fat JAR with all of it's dependencies merged inside, check this: How can I create an executable JAR with dependencies using Maven?).

If you really need additional files besides your executable JAR, you can still avoid an installer by distributing a compressed binary package with some auxiliary file structure around your JAR. Anyone can extract it somewhere in their system and run the main file. If necessary, you can also provide a batch file/shell in the root folder of this structure to help launching your app.

If you still prefer to sound less technical for users, you can also wrap that JAR into an executable file with an charmy icon by using Launch4j (http://launch4j.sourceforge.net/). You can even embbed a JRE in your file structure so the user won't need to install Java.

Before diving into installers complexity, you can also use a self-extracting archive just to ask for the user where to put the files. A lot of famous solutions work like this. Maybe you can even hide the files extraction phase and do it in the background everytime the application is asked to be launched (check this: https://www.excelsiorjet.com/kb/35/howto-create-a-single-exe-from-your-java-application).

I can only see the real need for an installer if you: need to check for previous system conditions (space, memory, dependencies); grant permissions to special folders and users; install your program on the default O.S. program files folder; set environment variables or Windows registry entries; create desktop shortcuts or system's menu entries; and a bunch of other tricky details. In this case, consider using an existing installer solution, since there will be a lot of hardwork involved until you can successfully accomplish such task. You already have to put so much effort to control your aplication codebase, not least another bunch of code for it's installer!

Rafael Odon
  • 677
  • 6
  • 12