How can i make up am installer for my java application (jar file) . The same as that of windows installer which proceeds by clicking next and installs the application. What i want with my java app is, the open source library xuggler to get installed if it is not already present in the system.Then i want JRE to get installed if it is not already present in the system.
If the user does not have xuggler or JRE installed , installer should automatically install the xuggler and JRE. Or it should tell the user to get that version of libraries from the given URL and then continue.
Your question is similar to this one:
how to package a java application
Advanced Installer has a separate edition especially for creating installers for Java apps, so this might be what you are looking for. I would recommend other tools but since they're scriptable, they're a hassle to work with, lots of things can go wrong.
Hope this helps
If your app. has a GUI, use deployJava.js for the JRE and then Java Web Start to install/launch the app.
An installer-desc can be specified in the JNLP file to install Xuggle. JWS can partition the download between OS.
JWS is supplied by the makers of J2SE JREs for desktop PCs (e.g. running Mac OSX, *nix or Windows).
NullSoft have a very good scriptable, opensource installer called NSIS.
http://nsis.sourceforge.net/Main_Page
I'm not aware of a cross platform way to do this. In the Windows world, you can use Wix to generate an MSI file, and in that file you can specify dependencies such as the JRE. In the Linux world you can generate a file with the dependencies read by the package manager, a deb file for Debian based releases for example. It's a bit of a faff to set things like this up separately, but once it's done you can just integrate it into your ant script and build everything automatically.
Related
Let's say I want to distribute a Java desktop app in a native-like way. Is there a tool/technique to build Java desktop application installers that will automatically and seamlessly install a JVM if one does not exist on a system already?
Installing Java apps for users who do not have a JVM is a 2-step process (first install the JVM, then the app). I'd like to match the experience of installing a typical native desktop app by making it a one-step process (or as much one-step-ish as possible).
For Windows, I suggest using NSIS installer to wrap installation of the JRE and your program. That will allow real "installation", ie. JRE will be installed to Program Files and it will be possible to uninstall it from Windows control panel ("public JRE"). You need to bundle the JRE installer for that.
Alternatively, you can bundle the whole JRE ("private JRE") together with your program. You can use Launch4J which configures the launch of your Java application (VM options, classpath etc.) as an EXE file, have the JRE somewhere as one of the folders of your distribution and point Launch4J to use it.
Or, simply have the unpacked JRE ("private JRE") in one of the folders of your distribution and use relative paths to use that one instead of the one installed on the system.
The advantage of a private JRE is that you control which Java version it is. With a public JRE, the user may be able to uninstall it or change the version and then come complaining that your program is not working ;)
For Linux, if you distribute you application as an RPM, you can just declare a Java package to be your dependency. Linux package manager should take care of it all. On the other hand, you can still bundle JRE in your own RPM to be independent of the "main" version installed on the user's machine.
A *.exe app made in java, to execute it needs to have java installed?
I transformed a *.jar into an *.exe and I don't know if it can run well in *.exe mode.
Generally yes you will need to have java installed.
It depends on the packager, Java knows nothing about .exes, so you used some external tool to package your exe as a jar. That tool COULD put the entire JVM into the .exe, but it's very unlikely.
Some also recompile it to native code (Jikes if it's still around is one) but that might still need access to jave install so it can get at the libraries... but it may also be able to re-compile the required libraries and include them in the exe
In other words, it all depends on the packager, look at it's documentation.
You will need something like exec4j:
https://www.ej-technologies.com/download/exe4j/files
From their website:
exe4j is a Windows launcher generator.
exe4j is useful if you want to create a Java launcher without an installer.
This will package your java project/JAR into a Windows .EXE file, and optionally bundle a JRE into the package so that your users are not required to have a local JRE already installed.
A JRE needs to be available at runtime for your application to work, so you can either bundle it into your executable, or have the user install one onto their system.
If your project is OpenSource, and has a website, generally EJ Technologies (the company behind exec4j, install4j, jProfiler, and other great Java technologies) will provide you with a free OpenSource License.
What's the best way to package Java software for running on Windows? Is there a standard for writing .BAT files which can discover the latest installed JRE on the machine? Are there any Maven plugins for this? What's the deal with executable Jar files?
I would without any doubt recommand you to use Java Web Start, as it allows you easy control over version used (and by far the easier to use update mechanism available nowadays).
Depends on what you need.
We've found that using the One-JAR + JSmooth gives a very good user experience as it allows us to distribute a single EXE-file which can be put anywhere on the users system, as opposed to having installation binaries, which need to be installed and uninstalled etc. etc. etc. JSMooth checks for the existance of the appropriate Java runtime, and redirects to the official download site if none is found.
The reason for One-jar is that you generally need to use library jars which is best to have separately but JSmooth only allows for a single jar file.
Also the One-Jar SDK and JSmooth is scriptable without being tied to Windows, so we can build new versions on our Hudson engine running on Linux.
In the past I've used a java installer package like launchForJ. However, a lot of these packages use Java so you may need to a batch or simple executable written in native windows code that does a quick check to see if Java is already installed then run the installer.
Since Java uses system variables during install you should be able to check if the version (or higher) that you require exists in this way.
The standard way would be to use Java Web Start.
Using Java Web Start technology, standalone Java software applications can be deployed with a single click over the network. Java Web Start ensures the most current version of the application will be deployed, as well as the correct version of the Java Runtime Environment (JRE)
Maven has a Webstart Maven Plugin to help building application bundles that can be deployed via Web Start.
An alternative solution would be to use a cross-platform installer generator to generate, well, an installer. I personally like IzPack (I think that JSmooth is very similar but I have more experience with IzPack) and, if you are specifically targeting the Windows platform, you could use IzPack to Build [a] Native Windows Installers with IzPack Native Launcher:
A problem still arise with IzPack when
the target system does not have a JRE
installed. The user needs to first
install it and then run the IzPack
installer. This is not a problem with
Linux or BSD users since they are
generally skilled and they know how to
do that by hand or with a packaging
system (RPM, DEB, ebuilds, ports,
...). Similarly, a Mac OS X user will
not have much problems since it is
available with the operating system.
However the situation is more
complicated on the Windows platform as
a JRE must be installed. Worse,
several instances can be installed in
a sometimes messy situation.
The IzPack Native Launcher tries to
solve this problem. It is a C++ native
application that is available under
the very permissive MIT License and
that uses wxWidgets for the GUI. It is
thus cross-platform (for the
historians: it was first developed on
a FreeBSD box), but most people will
need it on Windows. It uses a simple
configuration file and will first
check for a JRE. If none can be found,
it will pop-up a dialog to let the
user choose between the following
options:
manually specify a JRE location
download one from the Internet
install one that is provided by the packager (if available).
IzPack also offers a Maven Plugin. Worth the check.
These fine folks are my users: http://www.youtube.com/watch?v=o4MwTvtyrUQ
If you don't want to enjoy the video here is the gist: my users can't tell between a file and a folder, between a browser and a web site.
I need to create a Java web app (Tomcat or Jetty) and deploy it in as many of their computers, Windows and Mac.
The question is: Is there a mechanism to distribute an app with its own JRE? (in the Tcl world there are starpacks and starkits, in the Python world there's py2exe and others, that's the idea). And also, is it legal? I know the VM is open source but I'm not clear about the libraries, and I know about GNU Classpath but I don't know if all the packages are there.
I don't want to depend on the installed JRE or on the user having enough privileges to install one. On the Mac I don't want to depend on Apple (I had to switch from Tiger to Snow Leopard just to have Java 1.6, I can't put my users in that position)
Any info greatly appreciated.
Thanks!
jb
edit: I'm wondering if I can just paste the JRE folder under my app folder. Is that allowed?
We use Install4j at our workplace. It takes care of installation and installs the JRE if needed too. Its not free though. And at least the version we use doesn't provide Mac users with a bundled JRE. But as far as I was able to find out, that was due to some restrictions by Apple. Macs come with their own JRE and if your user has a Mac, its safe to assume they have a JRE installed. Although, if the JRE is an older version than the one you like, then they would have to use Software Update to check if a newer version is available and install it.
To run your application, a user needs the J2SE Runtime Environment,
which is freely available from Sun. Or, You can redistribute the
J2SE Runtime Environment for free with your application, according
to the terms of the Runtime Environment's license.
From http://java.sun.com/j2se/1.5.0/jre/README
I haven't read the fine print, it seems that Sun intends for people to redistribute the JRE. Also, there are many products (e.g. install4j) that make it easy for you to redistribute the JRE, so it seems to be legal.
As to the rest of it, you could then also bundle tomcat, with the built in Service so your app is automatically started, and create a shortcut on the desktop to your local webapp, so users are freed from typing ht tp://localhost:8080/webapp. There are plenty of FOSS installers (e.g. izpack) that will allow your users to install the package, and manage creation of desktop shortcuts. You mentioned preferring not using an installer, but even unzipping is kind of installing - your users have to choose a directory that they have write access to, and this is no different with a fully fledged installer.
But, given the capabilities of your users, is a locally installed solution the most suited to them? An online solution might offer simpler deployment (e.g. Java web start, or even as an applet.)
In OS X you pretty much are stuck with whatever Apple provides you. In other platforms, it is not needed to run a JRE installer (which you correctly point out your users may not be able to do), just bundle a JRE folder alongside your app. That is what many of our users do (my company has a multiplatform installer called InstallBuilder) and we have packaged many Java web apps that way. You can take a look at some of them at BitNami (they are all free)
Or in short, you can try this:
Make a self executable jar file of your app.
Provide your users small JRE setup (appx 15MB for jre6u7) along with your app.
Now create a batch file(for windows) which will first execute the JRE installer.
Then select path to installed JRE's 'bin' folder.
Now after this write 'java -jar yourAppName.jar' in the script to run your executable jar file.
eg: for win.bat write the following:
jre-6u7-windows-i586-p :: this will start the JRE installer
C:\Program Files\Java\jre1.6.0_07\bin\java -jar yourAppName.jar :: this will start your app
You can create such scripts for Mac and Linux also.
I need to build an installer that does the following:
Installs my jar on the client.
Auto-detects if JRE is installed (in which case it does not re-install it), otherwise installs it without the user clicking on another button.
Auto-starts the application when the client is booted.
Works across Windows, Mac and Linux.
Any idea how to go about it?
If a commercial tool is ok, I can recommend install4j. 1, 2 and 4 are easy to do with it, but about 3 I'm not sure. Edit: You could probably achieve that by installing your app as a "service", which install4j supports for all platforms. Quoting from its Features page:
install4j offers full support for
generating and installing services
(daemons). For services, install4j
generates service executables on
Windows, startup items on Mac OS X and
start/stop scripts on Unix/Linux
platforms.
Edit: Regarding #2, JRE detection: install4 has pretty nice, flexible options for JRE bundling/detecting. You can include a JRE (statically or dynamically, shared or not) or prefer to use one already present, with the possibility to download a JRE from within your installer as a fallback. Check these docs for more: How Installers Find a JRE and JRE Bundles.
(More about my experiences with install4j.)
For other tools, you could check some of the earlier Java installer questions on SO:
What’s the best way to distribute Java applications?
Java Application Installers
What is the best installation tool for java?
Commercial tools like InstallAnywhere can do that. After installing the JAR (and links and such), installers can check the registry if Java is already installed and proceed or not. As long as the installer supports all needed plattforms, you are fine.
You could use launch4j , it does not automatically install java however. But maybe there's a way to make that work by packaging the JRE for example.
You may also want to take a look at BitRock InstallBuilder, it provides built-in functionality to perform what you want. We will be happy to build a sample installer for you, just drop us a line.
I recommend downloading the source code for the build scripts of popular Java programs like limewire and follow their example. The end.
...Or you can do like I did:
I have done the JRE detection and
download/install of redistributable if required with
NSIS on Windows. Maybe an .msi is better than a installer.exe which NSIS creates. I believe msi are more like packages on mac so they allow proper updates. Maybe NSIS creates MSIs... not sure.
Mac is simply an Java App
bundle and you specify the JRE and other Java info in the
info.plist and you can optionally create a .pkg
file to give the user an installer and bundle up in a dmg using the command line dmg programs.
I haven't done Linux and don't plan to... sorry :)
All this was a fair chunk of work. I first did the Windows stuff then a couple years later did the Mac stuff.
You can integrate all of this in NSIS build scripts and Ant. I can't remember why I didn't use install4j. Probably I was too cheap :)
Haven't heard of anything that works across all those platforms, but JSmooth might help (fits your needs on Windows). I've used it about 2 years ago and it worked fine.