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?
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...
simple..
open the .sh file,
type ..
java -jar myJar.jar
now doubleclick the .sh file to run ur application
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).
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.
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/
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)
Related
We currently ship a java(jar) installer of our application. Taking into acount the changes to jdk11 we want our users to have the same easy install experience. So, what we are looking for, is to have just one file that can be run even if there is no java installed, it should just start our old java installer.
Probably, this means that we jave to bundle the jre and have a script that runs the jar, but the problem is how to run the batch file natively ? We need this to work on Windows and Mac. Most tools we are looking into require java to run the wrapped jar.
You have to build 2 different scripts/installers, one for each platform. Even looking at very popular software like Chrome, the platform choice is still there (even though you're usually directed to the correct choice based on the information your browser provides them with)
Depending on how much time you can put in this task, the quickest (and dirtiest) solution would be having an archive for each platform that contains the script .bat for Windows and .sh for OS X together with the jre (also different per platform), ask the user to unarchive and run the script which will run your jar with the packed jre. Otherwise, you'll need to create an MSI/exe for windows and a dmg (or other installer type) for MacOs.
I have done the dmg before with a bundled jre and can try to look for the details if you need them (I no longer have access to the code but can probably find the details). It was a free solution but it did require an OS X computer to create the dmg.
One option that I used before and works very well is install4j but the price is not small.
LE: Self contained packaging - although I haven't used this before, it seems like the best current option for your problem.
And an open source option - packr.
that Self Contained packaging doesn't really help, same for packr, same for launch4j. Because all those just generate a application image with a lot of files and directories.
Problem is before that, as an installer you want 1 big exe (or dmg for mac) that does it all, single click
We are already at the stage like SCP or Packr. Because that is easy or current installer.exe and jre\ sub dir and a batch/sh file besides it. Problem is how to get from that directory structure to a single exe that runs.
So what we should have is something that can zip that in a self extracting archive, when clicking on that it should auto extract to the temp dir of the OS, then run directly a command on it (like a batch file or directly in that extracted dir: .\jre\bin\javaw.exe -jar installler.jar)
But nobody seems to have made such a thing, the closest that we have is eclipse with Oomph:
[1] https://git.eclipse.org/c/oomph/org.eclipse.oomph.git/tree/plugins/org.eclipse.oomph.extractor/src/extractor.c
[2] https://git.eclipse.org/c/oomph/org.eclipse.oomph.git/tree/plugins/org.eclipse.oomph.extractor.lib/src/org/eclipse/oomph/extractor/lib/BINExtractor.java
problem is a bit that is doing the extracting through java and still wants a vm first.
I have created an project and need to distribute it over Windows. I need to create an exe for it I already know that there is a lot of tools like:
JSmooth
Launch4J
Executor
Advanced Installer etc.
The installer windows are done in Java itself. Means like the selecting locations, licensing etc. the only thing I need is to create an exe that should open this jar. Is that possible in Linux?
For a Java app. with a GUI, Java Web Start is the best option. It is supplied and maintained by the maker of the JRE, and therefore works on Windows, *nix and Mac.
I do understand the need for an .exe on Windows and I've used JSmooth before.
I would just make a shell script which launches the program. I think a shell script is fine for Linux: icons aren't built into the executable and you can't discover the location of a usable JVM automatically.
What's the best option for packaging and distributing a command line application written in Java, targetting OS/X and Unix?
The executable jar option seems fairly robust, and my distribution doesn't need to be super fancy, so right now I'm just thinking of plonking a bash script next to that with the relevant java invocation and being done with it.
I'm wondering if there's something similar to python's bdist package that would let me easily make nice installers for both target platforms. Or if there's some more obvious way that I'm missing where I can turn the entire distribution in to a executable file that wraps the jar in some way.
Since you are providing a CLI application it may be easiest to just provide the script you already mentioned. I usually try to keep it self-contained, e. g. not referencing external paths / using only relative paths etc. And maybe a readme.txt file.
If you would like to provide a full-blown installer, you might want to take a look at IzPack, a tool for generating installers for Java deliverables. It also allows the wizard to run in console mode, if you do not have a graphical environment available for installation (see the "Features" page in the link above).
I was asked to make a program (in java) by some person but I was stacked as I didn't know how to generate and exe file from my jar file... It would be useless If I install for them the jdk environment as this person don't how to program... Does anyone knows ho to do this or what tool should I use ?
Regards from Córdoba Capital, Argentina...Thanks in advance !!!
You could use launch4J, it's pretty simple to use and to configure.
Read this post, it may help
http://viralpatel.net/blogs/2009/02/convert-jar-to-exe-executable-jar-file-to-exe-converting.html
Regards
Thomas
Here is a post from earlier that has some other options:
How to create a Java application which can be run by a click?
As Lucas mentions above, you will need to install the JRE on the user's machine to get a Java app to run properly. If it is a small program, you could consider making a .bat file (or .sh file on *nux) to allow the user to run the program. Your bat file could as simple as the one below. Just put in a .bat file and add as a short cut. I know there are more elegant solutions out there, but this is simple and should work.
setlocal
set CP=<PATH TO ANY DEPENDENT LIBRARIES OR JARS>
start javaw -cp %CP% <FULLY QUALIFIED MAIN METHOD> <PROGRAM PROPERTIES>
endlocal
They don't need to install the entire JDK to run the jar file, all they need is the significantly smaller JRE. This is standard practice when distributing java applications.
A big advantage of running your java program on the jvm as compared to generating a native binary is that it will, assuming you aren't using a platform-dependent library, be platform-independent straight away.
You can use Excelsior JET. It is not free, work quite slow, but you can create executable (very huge executable). I tested it on Windows and it worked. But executable it created was slower then .jar run using JRE.
There is also GCJ. I tried it, but it was too hard for me to compile my project.
I suggest installing JRE and working with .jar file.
I have a Java application complied to a collection of jars that I want to make installable on Ubuntu and SuSE. I Want the installer to be able to check for the JRE, register a file association and be able to load a website on un-install.
I understand Ubuntu and SuSE are based on different architectures, so is there a consistent way to do this?
Does anyone have an advice on utilities to use or guides to read to help me achieve what I'm trying to do.
Distributing a deb and rpm for each platform would provide IMO the best user experience and system integration (checking the JRE dependency, registering file association, etc). For debian based distro, have a look at Packaging Java Apps for Ubuntu (slides are available here). To build a rpm, have a look at the RPM Howto or Development and Packaging Java Software for openSUSE.
If you don't want to build packages for each platform, I'd suggest to distribute an installer, for example with IzPack. This tool allows to generate a unique cross-platform installer, provides native integration, is highly customizable, covers the uninstall part and the generation of the installer can be easily included in an automated build (Ant or Maven based). It's really a nice tool. And it has serious references (Sun Microsystems, JBoss/RedHat, the Scala language project, some ObjectWeb/OW2 projects, XWiki, etc).
Try with this. This installer works with most Linux Distributions.
Insert into a .tar.gz archive your jars. if you want Create a menu entry on Programs menu create a "YOUR PROGRAM.desktop" file and put this script into that
[Desktop Entry]
Comment=YOUR COMMENT
Name=YOUR PROGRAM
#(Must same as .desktop file's name)
Exec=java -jar "(Path to Extracted folder)/myapp.jar"
Terminal=false
Type=Application
Icon=(Path to Extracted folder)/myapp.png
Categories=Development
OK, Now you can put it into a .tar.gz archive too.
Now you have to create "install.sh" file (file name is not important, It also works without extension - .sh)
Here is the code
#!/bin/bash
if which java >/dev/null; then<
sudo tar xvfz YOUR PROGRAM.tar.gz -C /opt #(Path for Extract Files)
mkdir ~/.local/share/applications
sudo tar xvfz DESKTOP.tar.gz -C ~/.local/share/applications
echo "Program installed.!"
else
echo "JRE Not Installed..!"
fi
read
exit
Bring all 3 files in same folder, Then run install.sh file(Must marked as Executable)I hope that, This will be Helpful for any one.
You can use BitRock InstallBuilder, it allows you to crete GUI installers, RPM and DEB packages. It can do what you specified (file associations, launch web pages, etc.) It is commercial but we have free licenses for open source projects and discounts for small companies
If you don't want to alienate users, do whatever you need to do to let the user manage your package using the tools native to that distribution (see Pascal Thivent's answer). For Ubuntu and SUSE, this means deb and rpm packages.
As a user, I immediately get irritated whenever I need to install packages with their own installers.
Take a look at InstallJammer if you're looking for a GUI installer. Otherwise, you might consider building a separate, native installer for each platform. RPM in the case of SuSE and DEB for Ubuntu. InstallJammer can give you a GUI and also register with the native package manager on each of those systems if you wish.
I had the same need for packaging a Java app as a Debian/Ubuntu deb archive but didn't find a proper guide, so when I succeeded in creating a deb archive, I wrote a guide of my own.
Basically, what I did was create a Bash script that arranges .class files, etc. in a file hierarchy ready for a .deb archive, writes an executable script to launch the packaged program, handle .desktop file for GUI handling, and then run dpkg --build on the whole thing. Also, an important step, run lintian -i on the resulting .deb file to make sure you're adhering to all standards and policies.