This is still awhile down the road for me but for my Project Implementation class we have to create a program and then distribute it. I have written an application in Java and from the specification I have made in the previous class (Project Design) my application will need to be platform-independent.
For mac and linux the user can just run the jar file from the terminal, but for windows I would like to have the Application installed to the path user chooses (default: C:\Program Files(x86)\NameOfApplication), Create a desktop shortcut (if the user wishes to have one), install under the start menu (if the user wants it to) and then also show up in the add\remove programs list.
Is there any easy way to do this?
Is it any harder if I did decided to create an installer for mac and linux?
Thanks in Advance.
You can create an installer with NSIS, even for a Java application.
You might also consider distributing your application via Java Web Start.
There are opensource installer generators for java. I have never used one before. Here is a good resource of links
I recommend using Java Web Start.
It has several advantages.
Available for all major desktop platforms
Single distribution for all JWS-enabled platforms
Code-signing and sandboxing
Versioning and incremental updates
Automatic installation of JREs and optional packages
It has one major disadvantage.
Internet connectivity is required if JWS, JRE, and/or an Optional
Package is not present on the system
Have a look here and here
Install4j does what you want, although you have to pay for it. Personally, I am not aware of any free alternatives. You can make installers for Linux and Mac OS as well.
you can use Exe4J, see http://www.ej-technologies.com/products/exe4j/overview.html
You can do most of that using standard JNLP:
http://docs.oracle.com/javase/1.4.2/docs/guide/jws/developersguide/syntax.html
You make a JNLP file that takes the executable JAR from some local (or remote) location and creates a Desktop icon for it (of your chosing). Only difference is that the actual JAR will be placed in the JDK's jar cache directory (not in a directory of your choice - I don't think the user would care much).
The huge advantage with this is that if you make a JNLP that installs the jar from a remote location, you can remotely upload a new version of the jar to that location, and when the user next accesses the jar locally, your latest version will be downloaded and placed into local cache.
Also I recommend you use a smart "fat JAR" builder, which packages all dependency jars inside the executable jar. Eclipse IDE has a way to export a project in this format (and also adds the necessary class-loader so that all works ok from on fat jar).
If your target OS is windows I highly recommend Advanced Installer. It's very very easy to use and will let you create your own native microsoft installer (.msi) with specific target Java VM and a bunch of useful windows features, even in the free version. Note you can also include a private jre into the package.
http://www.advancedinstaller.com/top-freeware-features.html
If you want a "package one deploy everywhere" solution then IzPack is the way to go, platform independant, free and open source.
http://izpack.org/
Depending on the complexity of your project Java Web Start could be a very good option, it's very simple configure and maintain but it relies on the browser's java plugin and believe me... most users DON'T like being warned about certificates and risks everytime they launch an application.
Related
I wish to package both my current system's JRE with a Java (JAR) application that I have created. On Mac I can simply create an app bundle and write a simple script to wire the two together. On Windows I am having trouble finding such a simple solution.
I tried launch4j, but to the best of my knowledge this does not let me package the JRE inside the executable; it must remain as a relative file.
I tried exe4j, but this also does not let me package the JRE within the exe.
My project does not use modules, so unclear how I can incorporate jpackage.
I want to distribute the file (as a portable non-installed app) to people working within my company. They are mostly somewhat computer illiterate, and will be scared off by seeing TWO files (one exe, one JRE).
I also do not want to deal with the headache of asking them to install a java runtime themselves, and end up with everyone having some different runtime. Simply, it is much easier for me to package the JRE with the Jar together as a single file and deliver to the end-user. We are doing this with our mac distributions, and everyone is happy.
When the program is installing on windows, I want the installer to check if mysql is installed, and install it if it isn't (Or at very least give a link to the website so the user can install it)
I'm sure this is possible, I've been trying to figure this out for a while now. If you can have an installer check if the user has java installed and install it if they don't, then surely you can do the same for mysql?
Perhaps I'm looking at this the wrong way - should I instead be getting the java program to check if mysql is installed and install it then if it isn't? And if so, how do I do that?
Any help would be hugely appreciated, I've been stuck with this for a long time.
I refer to this answer.
Java is cross platform, MySQL isn't, so you'd have to create various installers for multiple platforms with different MySQL binaries.
My suggestion is to have a look around the web in order to find the correct way to create an installer depending on the OS you're using
Installer is usually created for OS (Windows, Linux). In our case we created deb package (for Debian) which checked if PostgreSQL and other prerequisites are installed and installed what is missing. So, basically it is job for installation script (in our case it was shell).
Wix installers along with .bat files you can use.
http://wixtoolset.org/
It has built-in directives that can check if software is installed or not, outdated version notifications also.But WIX is kind of a database of your software binaries.So you have to include the binaries of MySQL(whichever are supported on windows) in the installer using harvest wix utility.
http://wixtoolset.org/documentation/manual/v3/overview/heat.html
This will just copy the binaries in your target directory if the software is not installed, you have to write all this logic to skip or install using wix directives/conditional custom actions .To do after copy stuff like starting or configuring the service either write a bat/powershell file which will handle all this and you can invoke this powershell file from wix after the copy action using wix custom action directives.
http://wixtoolset.org/documentation/manual/v3/wixdev/extensions/authoring_custom_actions.html.
Or you can write all the steps of bat files in many different custom actions.You will need visual studio to create this installer.In the begining it will be trouble to understand how it works but this is the best way to create production level deployment/product installers for microsoft suite.
I am developing one desktop application in javaFX. I am using in memory database hsqldb. I want to make this application to run on any windows machine by just double click or by installing.
I have gone through the launch4j library, using which I can make .exe file of my jar.
But if I create the .exe file, then I can open this application by just double clicking on it. anyone can copy and paste and open it.
I am confused with install word here.
What extra things will happens, if I want to make my application installable. Because I want to give an expiry date my application.
The answer to your question lies on the description of launch4j on their site.
The executable can be configured to search for a certain JRE version
or use a bundled one, and it's possible to set runtime options, like
the initial/max heap size
Not every machine you distribute the jar to may have a JRE. A bundled JRE will help the launcher run your jar if a JRE cannot be found on the target machine.
If you want to force updates on your jar, consider running a plugin mechanism or forcing the user to download a new version. It sounds to me like a web application might suffice instead ?
I was wondering how to include Java itself with a jar file so that people don't have to have Java installed already. Is it possible and if so, how do you do it?
To execute the jar in the first place you'd need to have java installed. So it would be best to include a JRE installer in a separate file if you'r including one. Also, you'd have to have a different installer for each target platform so this would be somewhat impractical for general distribution because of the inflated file size.
This is like asking "Can we include the chicken that lays the egg, in the egg?". Answer, no.
As to solving the bigger problem though, there is at least one strategy that might work well for applets, JWS apps. and (possibly) single Jars of desktop apps. that are launched from a link (I've never tried that, though). This approach uses JS to check for the right JRE before providing a link to the Jar.
In order to get a computer to do something, you need to have code that the operating system knows how to handle. Most modern operating systems do not know how to handle Java code unless you install a Java Runtime Engine - to them JAR files are just ZIP files.
Hence you need some code which can be executed directly (without Java) and the simplest is just to use a Java launcher. Many exist - see Java packaging tools - alternatives for jsmooth, launch4j, onejar - but e.g. launch4j is maintained and supports the <path> tag to specify a relative path to an included JRE. Those are unfortunately rather large, but you could provide two versions. One with the JRE, and one without (which then prompts the user to install a JRE).
I want to use QT Jambi for GUI (Java project). The GUI needs to have animations (similar to Iphone apps). That is why, I do not want to use Java Swing.
My question is, after I develop the application, is there any automatic mechanism which would create a setup file which could be used to install my application in any computer (may be separate "setup" files for separate OS). In other words, I would like my users to download just one file: setup.exe. This should install the app in their computer.
I know there is one such app for .jar files (I forgot the name). But QT is a C++ library and I do not like bothering the users, asking them to download QT just to use my app.
I presume you are tagetting win32 only on the desktop and looking for free/open tools. With no response to this questio so far I thought I'd provide some info towards this point even if it is not the answer you really want.
I have been looking over the QtJambi ecosphere for the past couple of years and I'm not aware of such a tool to provide you with a process to follow that results in an EXE. There are all kinds of caveats.
The task:
Ensure the JRE5+ is installed on target system.
Ensure QtJambi files and perform things like extraction of native JAR.
Ensure QtJambi pre-reqs are installed on the target system (such as MSVCxxxx runtimes).
Finally install your application and fixup the startup configuration to make use of information above.
Setup desktop fo reasy access (Program Group, Desktop Icon, Menu items, Shortcuts)
You will find that NSIS http://nsis.sourceforge.net/ can be a tool to get some parts of the process and maybe provide a framework to write modules for NSIS that do other parts of the work. But I have found NSIS somewhat lacking when you step outside of a simple unzip of data and setup of desktop install process.
Another solution for you would be to simply provide everything that works in one ZIP file, this would include a copy of the Java JRE embedded, a copy of QtJambi embedded, the rest of your JAR and then write a toplevel *.BAT file to setup %PATH% and other arguments to run your supplied java.exe against your application. Obviously now the JRE is not likely to get updated so at some point will be considered insecure.
NSIS isn't the only such windows installer that exist.
Maybe there is a fully automatic one click install wrapper with custom parts to help setting up QtJambi, but I doubt it at this time.
Good question, and one good attempt at an answer.
I've gone down a slightly different route: embed the Qt Jambi libraries, but not a JRE. I have some basic sh/bat launch scripts which configure the resources required and am using IzPack for the installer (though NSIS might be a good alternative).
Problem: how to find the JRE
Solution: the IzPack installer needs a JRE to run, so guarantees the availability of one. It can update a variable in scripts during installation.
Solution (Windows): use the registry
Last resort: use the path
The ideal would be to integrate all three into a batch file. Anyone done this?
Problem: Qt & Qt Jambi libraries
Solution: distribute with your application and link from the shell/batch file.
The problem with this is how to make sure your libraries get used when binary-incompatible Qt libraries are already installed on the system. On Linux, extracting the libraries and exporting LD_LIBRARY_PATH seems to work. On Windows I haven't solved this and on the Mac I haven't tried.
Problem: most appropriate Qt libraries
32-bit Qt libraries probably won't work with a 64-bit JRE; this is a problem I haven't yet had to deal with. Probably the best solution would be to include both 32-bit and 64-bit Qt libraries and select between them from a script at run-time (or possibly install-time).
Another issue is related to themes: Qt has support for using native themes, but only from the platforms it's compiled on. Thus, compiling Qt on an old Windows version and using the libraries on a modern version of Windows seems to work but results in ugly Windows-98-esque widgets. The easiest solution seems to be to launch with -style Plastique (or cleanlooks) to get nicer-looking widgets.