I have several Java applications. All of them have external jar dependencies and also require a couple of .dll/.so files to run. I want to build an installer for these applications, that will run properly just by double-clicking the installed program. What tools are available to do this ?
Thanks in advance.
For Windows Izpack is good tool. Also native implementation available.
But for Linux the best is to install it with a .sh script.
Edit
The reason for this is that when you use a .sh script, you can check if java is installed and install it if it's not present. As I am aware- Izpack still lacks this feature.
..run properly just by double-clicking the installed program
This implies a rich client desktop app. rather than one based on the command line. In that case, the best deployment technology is Java Web Start.
Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation for platforms that support Java.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
Related
I am not able to understand that after module system is introduced in our java language. Is java9 and above still platform independent or not ? I am asking this question because I have read that now every application will have its own jre inside it. So, how will this single jre run on all OS, like windows, Linux, or Mac OS.
You are conflating two different changes recently made to the Java platform:
Retiring of Java Web Start & Applet technologies
Modularization
Retiring desktop-technologies
Recently Oracle announced the phasing out of the Java Web Start technologies, in addition to the already-deprecated Applet technology. See item JDK-8184998 in Java 9 Release Notes:
Java Deployment Technologies are deprecated and will be removed in a future release
Java Applet and WebStart functionality, including the Applet API, The Java plug-in, the Java Applet Viewer, JNLP and Java Web Start including the javaws tool are all deprecated in JDK 9 and will be removed in a future release.
End-users will no longer be encouraged to install a JDK or JRE on their computer.
For more details, see the eight-page 2018-03 white paper from Oracle, Java Client Roadmap Update.
So then, how are developers of Swing or JavaFX apps to deliver their software to the end-user?
Oracle suggests packaging up your app along with a JVM & JRE for delivery as a single launch-ready applications on that appears on the client to be just another app alongside the native apps. Such “double-clickable” app-packaging has been commonly done on the Mac since the beginning of Java. But what was once an obscure art on other host environments (Linux, BSD, Windows, etc.) will now be the norm, as it is on macOS.
In yesteryear, bundling a Java runtime with your app required jumping over some licensing hurdles. The legalities have eased with arrival of the open-source OpenJDK project, and possibly with other implementations†.
You will need to prepare different releases of your app for each hosting environment. While your Java code runs independently of the host OS, the JVM is built of native code to interact with one specific kind of host. So you will need to build a Linux release with a Linux JVM, a macOS release with a macOS JVM, and so on. While that may seem like a downer, the upside is that you no longer need to worry about users having the wrong JVM version installed, or no JVM at all. Now the JVM’s presence and version are under your control. Your end-users and customers will no longer need to be aware that your app is Java-based.
Modularization
That need for app-packaging has nothing to do with the modularization of Java. As I said, it has been done for decades on the Mac.
What modularization brings to the party is that the JVM/JRE you bundle into your delivered app can be customized to contain only the Java Modules actually utilized by your particular app. This results in a smaller size, so your finished app is smaller, downloads are faster, less storage is used, and your app may load faster.
The open-source jlink “Java Linker” tool helps with the packaging work, so you can assemble and optimize a set of modules and their dependencies (only the ones actually called by your app) into a custom run-time image. This modular run-time image format is defined in JEP 220.
† On a related note, you may want to read the white paper Java Is Still Free to understand how and where to obtain a Java implementation for your app, and what support may or may not be offered in either free-of-cost or paid releases.
By the way, you may find helpful this Answer on a related Question, with a flowchart of choosing various sources of a Java implementation.
Is java9 and above still platform independent or not ?
Yes. It's as platform independent as it ever was. The module system has nothing to do with platform independence.
now every application will have its own jre inside it.
It doesn't have to, but it's more and more recommended as time goes on since fewer people have Java installed separately on their systems. This used to be a given, but that number has been declining for the last decade or so, and now (outside of Java developers) pretty much no-one has a standalone JRE installed.
how will this single jre run on all OS
It won't. You will bundle a separate JRE for each platform you want to distribute for. But JRE's for all platforms are still freely available, and the same Java code will still run on a JRE for any platform.
The module system doesn't influence the OS independency of java in general. Java applications that make use of the module system need to be run in a JRE. This can be either an OS specific pre-installed JRE as usual or a tailored runtime image (application embedded JRE) created with JLink.
The module systems main purpose is to provide you a managed way to split your application into different logical modules. E.g. into different .jar files that can be loaded at runtime - no matter on which operating system.
In summary, you have the following options:
Make sure that your client has the right JRE pre-installed. This could be dangerous, because (normally) you are not in control of his updating behavior.
Ship your application together with an official JRE.
Tailor your own, application and OS specific runtime image using JLink. Ship it bundled with your application.
But, suppose I do not know what OS my client would be running so how
the server will decide what image he should give to him. i.e., a Mac
Image, a Linux Image or a Windows exe.
You have to know the target OS and deliver the right runtime image.
While Java 9 makes it easier to ship a JRE which is more compact and specific to the needs of an individual application, you are not required to do so. If you were already planning to ship a JRE with your application it can be smaller with Java 9 than earlier versions.
It doesn't mean you have to ship a JRE, an application which wasn't shipped with a JRE is unlikely to start shipping with one now, and in fact Java 11 only ships as a JDK.
From this link on Java 9 features;
JLink allows you to create custom runtime images that only consist of your application modules and those JRE modules that your application requires. The result is likely a smaller runtime image, which uses fewer resources than a default JRE.
I have a JavaFX app that's currently assembled into an MSI installer package using WIX Toolset, bundled together with a certain JDK distributive (8u71).
The cause for the bundling is that after JDK version 8u71, there have been certificate recognition issues, and thus the app had to be made independent from Java updates - prior, WebStart was used to maintain installation and updates.
The difference now is that the MSI installer always requires administrator rights - both for installation and updating. This no longer suits the solution requirements.
The app is intended to be used under Windows 10.
So the question is: what options do I have available if I want to make updates not require admin rights? (initial installation requiring admin rights is fine)
E.g.:
Is it possible to somehow make WebStart use a user's local JDK installation instead of the machine-installed Java?
Can both JDK and Java App be installed in user context via an assembled installer (with WIX Toolset, or another tool)?
Is there a way to update a JavaFX app without actually having to launch the same kind of MSI installer used for initial installation?
Any other probable solutions?
I think the self-contained application packaging for JavaFX has the ability to create installers that don't require admin rights. If Wix isn't working for you, I suggest you use innosetup (the other option JavaFX provides to create windows installers). I think innosetup generates an EXE installer, not an MSI installer.
From the self contained packaging documentation, it is stated for EXE installations:
By default, the generated package has the following characteristics:
Admin privileges not required
Note on updates vs initial installs
You mentioned updates rather than installs in your question. I'm not aware of an updating framework for self-contained JavaFX applications, though you could research if one is available if the standard installers aren't providing the update capability you require. I'm not 100% sure on the capabilities of the standard installers (e.g. MSI/EXE installers via Wix or Innosetup) to handle updates rather than just app installs.
Note on userspace vs system wide installations
My understanding is that JavaFX allows you to choose which method (userspace or system wide) to use, at packaging time for some packaging tools (e.g. Wix or Innosetup, though I would not know which allows what options). Just read the linked documentation, it explains your options for this better than I could.
I want it like when we do "open with" and then choose Notepad. So that when I "open with" a file there will be my program in the list. How to associate a file type with my program?
How to make the program handle the file?
Deploy the app. using Java Web Start.
Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation for platforms that support Java.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
This demo. of the file service is deployed using JWS (on OS X, *nix and Windows) and declares an interest in the .zzz file-type.
Best thing would be to create an EXE wrapper for your Java program:
How can I convert my Java program to an .exe file?
and
Best free tool to build an exe from Java code?
are relevant. Then you would need to create a file association. See this KB article on how to do it manually:
http://support.microsoft.com/kb/307859
If you use an installer package to package your app you would have to research on how to accomplish this automatically when your program installs.
I need to create an installer for my java desktop application. I don't like to code an installer by hand. is there anyway I can create an installer for Java applications?
If your looking to create an installer for windows applications check out Advanced Installer. For linux based machines, I'd just got with the regular tar.gz file and a README file.
Pack Jacket software:
This is a freeware with a simple GUI. Available to download from sourceforge. This file is capable of creating installers with extensions .exe, .jar and much more. The complete tutorial is available in youtube. Just search "How to make installer for regular java project" in youtube and the first result, you will find the tutorial (I tried to paste the link here, but stackoverflow didn't allow it :( ).
IZPack:
IZpack doesn't have any GUI, just some files. You have to do it manually. It takes xml files as parameters which instruct it how to create the installer. The tutorial for using IZpack is here. I am using IZpack and personally I like it more than pack jacket.
There are more apps for creating these installers, but according to my knowledge these are the most famous because I have seen these installers in number of applications I have used.
Hope you can make your work easy by reading this :)
..installer for my java desktop application.
Deliver it over the net using Java Web Start.
Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation for platforms that support Java.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
I have written an updater program for my friend to update another program I wrote for her as a going away gift. I have written all the needed code for retriving the class files that are updated from a server and holding them in temporary memory. What I need help with is having the program replace the class files in the first jar file so she doesn't have to do manual updates. Note: The main program is not running during update so no exploding jars.
So long as the app. has a GUI, deploy it using Java Web Start.
Java Web Start (JWS) is the Oracle Corporation technology used to launch rich client (Swing, AWT, SWT) desktop applications directly from a network or internet link. It offers 'one click' installation1 for platforms that support Java.
JWS provides many appealing features including, but not limited to, splash screens, desktop integration, file associations, automatic update2 (including lazy downloads and programmatic control of updates), partitioning of natives & other resource downloads by platform, architecture or Java version, configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.), easy management of common resources using extensions..
It is easy for the user.
Automatic update is built-in, all the deployer has to do is upload the new Jar.
If Java Web Start is not what you're looking for and if the jar executable is available on your friend's computer (either because a JDK is installed on your friend's machine or you distribute it with your application), you can run
jar uf jar-file input-file(s)
If you want to call the jar executable from within a Java program, just use Runtime.exec. For a more in-depth discussion about updating a JAR via the jar executable, see Sun Developer Network's article "Updating a JAR File."