views:

326

answers:

6

How can I create a linux installer for java desktop application? for an instance if we want to install netbeans on ubuntu there is a download which is named as "netbeans-6.8-ml-java-linux.sh" so how can i create "mydesktopapp-linux.sh" i have the properly working .jar file i want to distribute my java desktop app. Can anyone help me?

A: 

simple..

open the .sh file, type ..

java -jar myJar.jar

now doubleclick the .sh file to run ur application

echo
no not like that i want one .sh file which has my package like netbeans
A: 

Introduction to shell archives
http://linux.die.net/man/1/shar
http://www.rpmfind.net/linux/rpm2html/search.php?query=sharutils

This might work for you as well:

makeself - Make self-extractable archives on Unix

makeself.sh is a small shell script that generates a self-extractable tar.gz archive from a directory. The resulting file appears as a shell script (many of those have a .run suffix), and can be launched as is.

http://megastep.org/makeself/

Dmitry Yudakov
+3  A: 

I recommend you to have a look at IzPack. IzPack is a one-stop solution for packaging, distributing and deploying applications.

It is fully cross-platform and generates a single installer. As such, it is an alternative to native solutions such as platform-specific installers and package managers.

There are many other alternatives, but IMO IzPack is as good as they get and is completely free. If your app targets only Unix/Linux hosts you might consider creating native packages like RPM, DEB, etc...

Bozhidar Batsov
+1 for mentioning RPM, DEB, etc. For Ubuntu, creating an apt-get repository is the proper way to go.
Michael Aaron Safyan
A: 

On Linux/Unix, the *.sh suffix identifies a shell script. These scripts are simple text files, starting with the special #! notation on the first line, which specifies the shell that will run the commands in the file.

Like the netbeans-6.8-ml-java-linux.sh you mentioned, your script should start with #!/bin/sh to reference the Bourne shell.

As mentioned already by raj, a simple

java -jar myJar.jar

command could be the minimal contents to launch your app from the jar.

You can then make your launch script arbitrarily complex in order to deal with different locations of the java executable, handle insufficient permissions, providing nice help messages, etc. (again, have a look at netbeans-6.8-ml-java-linux.sh to see what I mean).

netzwerg
File extensions mean nothing in Unix. Additionally #!/bin/sh is not necessarily bash (unless it's linked symbolically in the background). Use #!/bin/bash if you expect your shell to be bash.
gpampara
Thanks for pointing this out, gpampara. Of course you're right -- file extensions mean nothing in Unix. Is it safe to state that it is a *convention*, that *.sh files identify shell scripts? Why would he need to use bash? I was referring to #!/bin/sh and mentioning the Bourne shell because this is what his netbeans example uses -- the Bourne shell binary "is located at /bin/sh on most Unix systems" (http://en.wikipedia.org/wiki/Bourne_shell).
netzwerg
@netzwerg: you didn't say that it would be the bash, but some people expect all bourne shells to be bash (which is of course false), so explicitly mentioning it can be helpful.
Joachim Sauer
you cant open netbeans-6.8-ml-java-linux.sh from gedit its kind of a compressed file have you installed netbeans? if not download it and see its different. i want to make my application like that
Try inspecting it with 'less -N'. The file is not compressed, but very big, so maybe gedit just refuses to open it because of its size? The binary part starts at line number 2145, but everything before is readable plain text.
netzwerg
Concerning the creation of your deployable script: This HOWTO (http://tinyurl.com/dxayd7) explains how to append a binary file to the textual part. In contrast to the example, you wouldn't append a tar.gz, but your jar, and instead of unpacking it, you would run the "java -jar myJar.jar" command. Hope this helps...
netzwerg
A: 

You should take a look at InstallJammer. Not only can it build a cross-distro installer that would be easy for newbies to use, it can also register itself with the native RPM or DEB package manager so that the user can uninstall through the common system.

Damon
I've used this before, it's pretty well-featured (not as much as Windows installers though) and easy to use. Plus, if you have questions, the author is pretty quick to answer them on the discussion board. If you want a GUI installer it's a good choice.
Chris
A: 

In addition to makeself and the other tools mentioned in the thread, I suggest taking a look at my tool, BitRock InstallBuilder It is capable of creating self-contained executables that can be downloaded and launched but unlike some of the other tools do not require a self-extraction step. That means the installers start faster and no extra disk space is wasted. It is commercial, but reasonably priced (and we have significant discounts for solo developers and smaller companies)

Daniel Lopez