High level: I am working on a JavaFX app that I'd like to automatically update
Things I've looked at:
Add ability to automatically update co-bundled app (Open JDK official auto updater issue)
UpdateFX (Library for handling automatic updates)
Issue I am having: Trying to package two separate javafx native executables into one package.
Description:
I have created a JavaFX UI application that checks for an updated version upon startup. The application is delivered by building a native (using jfx packager) package for each OS: Liux, Windows and OSX.
If there's a newer version available the app downloads the required update into a temporary folder.
To update itself, the app technically needs to overwrite some of its own files. While this is possible to do on Linux and OSX, Windows locks all of the jar files that I need to update while the main application is running.
To get around this, I created a small "updater" application that I would download. My main application would download all of the updates AND the updater application. The main application would then launch the updater and kill itself.
The updater would continuously try to update that application files (this was in some kind of loop in case it took a while for the main application to shut down).
Once the updater would finish, it would simply call the correct main program's executable file and the update would be completed.
This works...BUT: In order to run my updater application, I am relying on the client's machine having java (and having the correct version to boot). The whole point of using the javafx native packager is to make sure that the JRE is distributed with the app and that there is no dependency on any local version.
I wanted to try a hack:
Instead of having my updater be a regular jar (java application). I could make the updater be a JavaFX application that I package natively.
I'd then manually take the generated native executable out of the updater and just distribute it with my main application.
Since the folder structures for both main executable as well as updater executable would be the same, I was hoping that both executables could piggy back on one bundled JRE
The hack only works on OSX - on both windows and linux there are local config files that the executable relies on to invoke the correct java file.
Is there any way to get around this issue? Is there any way to force the packager to output a custom "package.cfg" (in the case of windows) that would allow me to bundle two executables?
I realize this is a long shot, but any advice would be appreciated.
I may have asked my question just a bit before the code to do what I wanted was included in javapackager.
Short story is that this is now possible to do using javapackager that is part of JDK 1.8 release > 60 (I am now using 74)
Here's a link to the official oracle documentation: Oracle Doc
It's also possible to use Maven to build your JavaFX app to have secondary launchers via: javafx-maven-plugin
Related
I am working on a large JavaFX application which is due for deployment. I want to wrap the .jar files with Launch4j and create an installer using Inno Setup. However, I am having trouble with the process.
When using Launch4j, it spits out these errors (see 1). However, despite these errors, everything works perfectly fine using an MWE I created to verify that Launch4j wraps jar files properly. The MWE is just a small JavaFX application, where I use Launch4j to generate an .exe file and use Inno Setup to generate an installer. I can install this MWE with no issues using the generated installer and run the app. As mentioned, however, when I follow this exact same approach for my large application, which does have a lot more dependencies, I am not able to run the application after using the generated installer.
I searched for solutions to this and found this work-around using Inno Setup (see ban-geoengineering's answer):
How do I bundle a JRE into an EXE for a Java Application? Launch4j says "runtime is missing or corrupted."
I followed the steps mentioned but am still not able to run the application after generating the jar wrapper with Launch4j and running the generated installer created by Inno Setup. When I try to run the app, simply nothing happens.
Application information and development environment
The application utilizes custom-made java libraries developed in-house which act as an intermediary to communicate with a device's eSW through a custom interface. These java libraries and device drivers are needed in order to communicate with the device and need to be delivered with the application, as in included with the installer. I am using IntelliJ IDEA 2018.1 under Windows 10 Enterprise. The JDK is version 9.0.4.
Steps taken prior to using Launch4j and Inno Setup
I have followed the steps mentioned here https://www.jetbrains.com/help/idea/creating-and-running-your-first-java-application.html#package to package the application. I can successfully run the application via the commandline using java [options] -jar nameOfJar. The application needs certain VM options in order to communicate with the device drivers, and I am suspecting the issue lies here when generating the .exe file and generating the installer.
Addition 1
I have tried to add a custom classpath in Launch4j. It seems that Launch4j does identify the jars that the main class is dependent on, as it includes all the proper jar files (see 3).
I have in addition to this tried to mimic the JVM options I use to run the application via the commandline (see 4).
When executing the application it spits out NoClassDefFoundError and says it is due to the com/demant/gearbox/corona/model/GBCManager. However, this should already be included via the jar file com.demant.gearbox.corona.model.jar, as you can see in 3.
But, as you can see from both 3 and 4 the NoClassDefFoundError is still thrown.
I have an OS X objective-c app which programmatically invokes the Java command to run a Java program.
If I'm correct, Java is no longer installed by default on OS X. I want to ship my app and not force users to download Java before they can use the app.
How can I ship a copy of the java executable along with the runtime (rt.jar). Of course I can copy rt.jar in the app bundle of course but what about the java binary? Can I just copy this as well?
I think in your case, the best option would be to include the Java Installer Kernel (small install that downloads and installs the latest version of Java, if necessary).
The main problem with bundling the binaries per-se in your app is basically, security. Vulnerabilities are discovered routinely in the JRE and patched. If you bundle an specific version and a vulnerability is discovered after your release, you will be basically weakening the security of the machines where your application is installed. As you obviously don't want to do that, it is better to try to include logic to detect if a compatible version is present, or otherwise properly install the right version. Many installer packages include options like this: For example, OpenOffice/LibreOffice are native apps but they require Java to be present, and they use a similar installation method as the one described above.
Each self-contained application package includes the following items:
Application code, packaged into a set of JAR files, plus any other application resources (data files, native libraries)
Copy of the JRE, to be used by this application only
Native launcher for the application, multiple launchers for a single package are supported
Metadata, such as icons
Multiple package formats are possible. Built-in support is provided for several types of packages. You can also assemble your own packages by post-processing a self-contained application packaged as a folder, for example if you want to distribute your application as a ZIP file.
--
Self-contained application packages have the following drawbacks:
"Download and run" user experience
Unlike web deployment, the user experience is not about "launch the application from the web." It is more one of "download, install, and run" process, in which the user might need to go through additional steps to get the application launched. For example, the user might have to accept a browser or operating system security dialog, or find and launch the application installer from the download folder.
Larger download size
In general, the size of self-contained application packages is larger than the size of a standalone application, because a private copy of the JRE is included.
Package per target platform
Self-contained application packages are platform-specific and can only be produced for the same system on which you build. To deliver self-contained application packages on Windows, Linux, and OS X, you must build your project on all three platforms.
Application updates are the responsibility of developer
Web-deployed Java applications automatically download application updates from the web as soon as they are available. The Java Autoupdate mechanism takes care of updating the JRE to the latest secure version several times every year. Self-contained applications do not have built-in support for automatic updates.
You can ship a JRE with your app (see licensing). To give the user a copy of JRE, put one in and let them install it themselves or make a application bundle.
Is it possible that to run a JavaFX Application at windows boot time. what efforts i can make so that my java application automatically starts when windows(OS) start or boots ? (after displaying a windows logo, before desktop mode load)
I've had success packaging JavaFX applications into an .exe using the JavaFX Maven Plugin (https://github.com/javafx-maven-plugin/javafx-maven-plugin). You even have the option to bundle a JRE with it so it doesn't need to rely on the system's installed JRE. I imagine once you create the .exe, you can simply add it to your "Startup" folder. (https://support.microsoft.com/en-us/kb/2806079)
You may want to check out this link. The program "AlwaysUp" has unrestricted 30-day trial version. Try that and if you like it and don't want to pay for it, you can find the full version from torrent.
I have an existing Java 6 application that works on a Mac and recently began the switch to use Java 7.
I already made the switch from JarBundler (the old Java 6 utility for creating an application bundle) to Oracle's AppBundler. This appears to be working as expected. I can launch the new Java 7 application by double clicking it from the Finder window. I can even manually move the application "Applications" folder and it also works fine.
When I use the Iceberg utility to create an installer I run into a problem.
The installer is created and works as expected until I look into the Applications folder after running the generated package installer (.pkg).
When I double click on the application nothing happens. Also it is not picking up the .icns file to display the launch icon (it just display a generic application icon).
I tried comparing all of the files in the Applications Folder to the Application package and they appear to be the same.
I have tried everything I can think of including switching to pkgbuild and productbuild. These tools had the same behavior as Iceberg.
Any help on this would be much appreciated.
Welcome to hell. Please stay for a while.
I do not know, why Oracle chose not to use the same structure of the old plist.info and Mac App Bundles. There are a lot of problems associated with the new AppBundler (esp. resource path ...). Please have a look at:
https://github.com/tofi86/universalJavaApplicationStub
Java AppBundler application pointing to JRE defined by JAVA_HOME
https://bitbucket.org/infinitekind/appbundler
I have made sample application with JavaFX using netbeans 7.2. When I run application from netbeans it is working fine. Now I want to distribute this application as the standalone application.
So I am trying to opening this application from the executable jar file made by netbeans itself in the dist folder. But I am getting error : Unable to Load JavaFX runtime
How to resolve this issue ??
Also I wanted to know the best way to distribute this application as desktop standalone application ? Means I wanted to know the final package for distribution would it be executable jar file ?
For this final package(suggested for above question) will there be any prerequisites for the application to run on windows environment ? : This is importance because our final environment is very limited. It don't have even java installed on it.
I don't know why launching the executable jar created by NetBeans does not work for you.
You can workaround this issue by packaging your application as a Self Contained Application. Such a package includes the java and javafx runtimes with your application so you never need to worry about distribution and installation of these things to your client. In any case, it sounds like such a package is a good fit for your application.
A self-contained application is a wrapper for your JavaFX application, making it independent of what the user might have installed.