可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
回答1:
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).
回答2:
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.
回答3:
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
回答4:
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.
回答5:
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.
回答6:
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.