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."
Related
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 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..
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..
All:
I am facing a problem here, my app is composed by some jar files and some other files, they are all located in one directory. I am planning to implement an auto-update feature. When the app know there is a new version on the server, it will download a zip file to temp directory. After downloading, it will ask customer if he'd like to install it. If yes, my app will exit and I need to unzip the zip file and overwrite all files in the original directory. Now I am wondering:
How can I unzip the file and overwrite the directory? Create a script (which means I need to write bat for Windows and shell for other platforms)? Create a java class to do it?
How can I start this script/ java class after exiting?
Once the job is done, how do I delete the installer? Keep it in temp directory and check it out when new version app start?
From later comments:
I know JWS is a good choice, but for reason "my boss denied", I can't use it.
There could be several approaches. Since you say the application is cross-platform, it would be wise to use Java for update.
You can create a small jar file which will handle the update process. It could be part of the initial application (with the assumption it won't be updated) or it could be part of the update package (then you can update it as well).
So your application downloads zip, unpacks it to a temporary directory and starts the updater, then it exits. The updater copies new jars over the old ones.
Yet it's better to not reinvent the wheel. Consider using JWS: it provides more features and requires less effort to implement. There must be good reasons to deny JWS. You should persuade your boss by explaining the benefits of using JWS.
Since the app. has a GUI (judging by the Swing tag), 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' 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..