JavaFX native App Auto-update feature implementation Fxlauncher

Source: Internet
Author: User

The implementation of the automatic update function of JavaFX native application is--fxlauncherchszs, not reproduced without the permission of the blogger. Permitted reprint should be marked by the Author and blog homepage: Http://blog.csdn.net/chszs, Javapackager Introduction

JavaFX has become one of the best UI frameworks for building modern desktop applications, but it has always been a problem of deployment inconvenience. The Javapackager tool is a solution to this problem, and as JavaFX has been packaged into JDK 8, the Javapackager tool is also available with JDK 81.
The Javapackager tool makes it easy to create a local app installer, but unfortunately, Javapackager does not support automatic Updates. Java WEB Start can support update operations, but it cannot package local apps.
The Javapackager tool can perform packaging and signing tasks for Java applications and JavaFX applications.

语法: javapackager command [options]

Command includes:
1)-CREATEBSS
Convert CSS files into binary form
2)-createjar
Generating jar documents based on other parameters
3)-deploy
Generate a basic Application release package (which can be a self-contained application release package)
4)-makeall
Execute the compilation, Createjar and deploy will call it
5)-signjar
To sign an application based on the certificate provided

Ii. introduction of Fxlauncher

The Fxlauncher tool combines the Javapackager local installer feature with the Java WEB start similar update mechanism, enabling the use of fxlauncher without the need for a local installation package and the release of only 14KB of runnable jar files (launcher) , download the individual modules of the app and keep the app's version updated with an online installation.

Launcher the contents of the application's manifest file (App.xml), and the manifest file is used to synchronize the local artifact at startup.
When manifest is loaded, the user will see an animation like this:

When the application starts updating, the user will see an animation like this:

The preloader then controls the application process. Launcher appears to be configured using CSS.

Example of the contents of the manifest file (app.xml):

<Application uri="http://fxldemo.tornado.no/" launch="no.tornado.FxlDemo">    <lib file="controlsfx.jar" checksum="1589854040" size="954085"/>    <lib file="fxldemo-2.0.jar" checksum="223197943" size="4865"/>    <updateText>Updating...</updateText>    <updateLabelStyle>-fx-font-weight: bold;</updateLabelStyle>    <progressBarStyle>-fx-pref-width: 200;</progressBarStyle>    <wrapperStyle>-fx-spacing: 10; -fx-padding: 25;</wrapperStyle></Application>

The local installer does not contain any code, so you do not need to rebuild the application when it publishes the new version, simply copy the application's artifact to a predefined location, and Fxlauncher will handle the rest of the work.

Fxlauncher can also handle applications in a variety of programming languages, and it works very well with TORNADOFX.
Examples of fxlauncher and tornado combinations: http://fxldemo.tornado.no/

Third, the use of fxlauncher steps

1) Compile the project jar to App.dir
2) Copy dependency package to App.dir
3) Generate App.xml Manifest
4) Create a local installer
5) upload artifact to Automatic Update warehouse

Copy the deployment descriptor and modify it as you want it:

<properties>    <!-- 应用程序名 -->    <app.filename>${project.name}</app.filename>    <!-- JavaFX应用的入口类 -->    <app.mainClass>no.tornado.FxlDemo</app.mainClass>    <!-- app和launcher存放位置 -->    <app.dir>${project.build.directory}/app</app.dir>    <!-- 本地安装器存放位置 -->    <app.installerdir>${project.build.directory}/installer</app.installerdir>    <!-- 托管应用artifact的基础URL -->    <app.url>http://fxsamples.tornado.no/demo/</app.url>    <!-- Optional scp target for application artifacts hosted at the above url -->    <app.deploy.target>[email protected]:fxldemo</app.deploy.target></properties>
Iv. maven Goals

1. Generate the Application

mvn clean package

2. Deploy the application artifact to your own Web server

mvn exec:[email protected]

3. Setting up local installers

mvn exec:[email protected]
V. Introduction of TORNADOFX

TORNADOFX is a lightweight JavaFX framework for Kotlin languages. Features of the TORNADOFX include:
1) Dependency Injection
2) Type safety builder
3) Asynchronous Task execution
4) MVC
5) Extremely lightweight
6) Small and simple API
7) Rest client provided for model object
8) 0 configuration, no XML, no annotations

Https://github.com/edvin/tornadofx

Tornado's maven dependency:

<dependency>    <groupId>no.tornado</groupId>    <artifactId>fx</artifactId>    <version>1.2.3</version></dependency>

JavaFX native App Auto-update feature implementation Fxlauncher

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.