Documentation Contents
Java Platform, Standard Edition Deployment Guide
Contents    Previous    Next

4 Application Startup

This topic provides information about the application startup process, user experience, and customization options.

The user experience is an important factor in making an application successful. The deployment of an application creates a user's first impression, and impacts the user's satisfaction with the application.

In this topic, the default experience for users of Java and JavaFX applications is explained, and the options for customizing the user experience are presented. This topic contains the following sections:

4.1 User Experience Considerations

Users are easily annoyed if they are unable to start an application, do not understand what are the next steps, perceive the application as slow or hung, and for many other reasons.

Default Java packaging takes care of many problem areas including:

For example, when users do not have Java installed and double-click the JAR file for your application, they see a dialog box explaining that they need to download and install the JRE.

Developers have a wide range of options on how to tune the experience for their users, such as:

4.2 Application Startup Process, Experience, and Customization

The following sections describe the transition phases of application startup, how users experience those phases, and how the default visual feedback to the user can be customized.

4.2.1 Startup Process

Between the time an application is started and the time the user sees the main dialog, a sequence of events occurs on screen while operations are carried out in the background. Figure 4-1 shows these activities and describes them in the following paragraphs. This startup sequence partially depends on the execution mode and on the speed with which the background operations complete. Figure 4-1 shows a series of boxes that depict the background operations over time, including screen shots of what the user sees as these operations occur for a JavaFX application.

Figure 4-1 Background Operations and Screen Events During Application Startup

Description of Figure 4-1 follows
Description of "Figure 4-1 Background Operations and Screen Events During Application Startup"

The application startup process has the following phases:

4.2.1.1 Visual Feedback During Phase One Initialization

Options to provide visual feedback during the first phase of initialization are limited. At that moment, it is not yet known what must be done to launch the application, and the Java platform has not initialized yet. Visual feedback must be provided using external means, for example using JavaScript or HTML if the application is embedded into the web page. By default, a splash screen is displayed during this phase, as described in Section 4.2.2, "Default User Experience."

4.2.1.2 Visual Feedback After Initialization

To provide visual feedback after the initialization phase of a JavaFX application, JavaFX provides a preloader, which gets notifications about the loading progress and can also get application-specific notifications. By default, a preloader with a progress bar is displayed during this phase, as described in Section 4.2.2, "Default User Experience."

You can customize the default preloader, as described in Section 4.2.3, "Customization Options for JavaFX Applications." You can also create your own preloaders to customize the display and messaging. See Chapter 12, "Preloaders for JavaFX Applications" for information.

For Java applets, a custom progress bar can be provided. See Section 13.3.2, "Implementing a Customized Loading Progress Indicator" for information.

4.2.2 Default User Experience

A properly packaged application provides default visual feedback to the user for the first two phases for all execution modes. The actual behavior depends on the execution mode and type of application.

When launched in standalone mode, most applications start quickly, and no visual feedback is required.

Table 4-1 summarizes the default behavior according to execution mode when the application is launched for the first time and is loaded from the network.

Table 4-1 Default Behavior During First-Time Launch

Startup Phase Java Web Start Launch Embedded in a Web Page

Phase 1
Initialization

Splash screen:

Description of java8_splash.gif follows
Description of the illustration java8_splash.gif

Splash screen, JavaFX applications:

Description of html_splash_75.gif follows
Description of the illustration html_splash_75.gif

Splash screen, Java applications:

Description of html_splash_se8.gif follows
Description of the illustration html_splash_se8.gif

Phase 2
Loading Code

Progress window, JavaFX applications:

Description of ws_load.png follows
Description of the illustration ws_load.png

Progress window, JavaFX applications:

Description of progress_dialog2_40.gif follows
Description of the illustration progress_dialog2_40.gif

Phase 3
Transition to Application

Hide progress window

Fade-out progress window, JavaFX applications


Table 4-2 summarizes the default behavior for subsequent launches, in which the JAR files are loaded from the cache. In this case, the process has fewer visual transitions because nothing needs to be loaded from the network during the Loading Code phase, so launch time is substantially shorter.

Table 4-2 Default Startup Behavior During Subsequent Launches


Java Web Start Launch or Launch from Shortcut Embedded into Web Page

Phase 1
Initialization

Splash screen:

Description of java8_splash.gif follows
Description of the illustration java8_splash.gif

Splash screen, JavaFX applications:

Description of html_splash_75.gif follows
Description of the illustration html_splash_75.gif

Splash screen, Java applications:

Description of html_splash_se8.gif follows
Description of the illustration html_splash_se8.gif

Phase 2
Loading Code

Splash screen:

Description of java8_splash.gif follows
Description of the illustration java8_splash.gif

Splash screen, JavaFX applications:

Description of html_splash_75.gif follows
Description of the illustration html_splash_75.gif

Splash screen, Java applications:

Description of html_splash_se8.gif follows
Description of the illustration html_splash_se8.gif

Phase 3
Transition to Application

Hide splash screen

Hide splash screen


4.2.3 Customization Options for JavaFX Applications

The splash screen for embedded applications is displayed in the web page and can be easily customized by using an onGetSplash callback, as shown in Section 17.2.3, "onGetSplash."

The default JavaFX preloader can be customized by using a CSS style sheet, similar to other JavaFX components. Pass the customized style data using the javafx.default.preloader.stylesheet parameter for your application. The following items are valid for the parameter:

To customize the preloader, use the .default-preloader class. In addition to standard CSS keys, the preloader has the following special keys:

Example 4-1 shows an example of CSS file my.css:

Example 4-1 Example CSS Class to Customize the JavaFX Preloader

.default-preloader { 
    -fx-background-color: yellow; 
    -fx-text-fill: red; 
    -fx-preloader-graphic: url("http://host.domain/duke.gif"); 
    -fx-preloader-text: "Loading, loading, LOADING!"; 
} 

Add the style sheet to the <fx:deploy> Ant task as shown in Example 4-2:

Example 4-2 Adding a JavaFX Preloader Stylesheet to the <fx:deploy> Ant Task

<fx:deploy ...>
    <fx:application ...>
        <fx:htmlParam  name="javafx.default.preloader.stylesheet" 
                value="my.css"/>
    <fx:application>
</fx:deploy>

If only a few customizations are needed, pass CSS code instead of a file name, to avoid the overhead of downloading a file. Example 4-3 shows how to change the background color to yellow.

Example 4-3 Changing the Default JavaFX Preloader Background Color

<fx:deploy ...>
    <fx:application ...>
    <!-- Using fx:param here, so it will be applicable to all web
            execution environemnts -->
        <fx:param  name="javafx.default.preloader.stylesheet"
                value=".default-preloader { -fx-background-color: yellow; }"/>
    <fx:application>
</fx:deploy> 

To add a company logo to the default JavaFX preloader, you could pass the following string as a value of the javafx.default.preloader.stylesheet parameter :

".default-preloader { -fx-preloader-graphic:url
('http://my.company/logo.gif'); }"

If customizing the default JavaFX preloader is not enough and you need a different visualization or behavior, see Chapter 12, "Preloaders for JavaFX Applications" for information about how to implement your own preloader, and see Chapter 5, "Packaging Basics" for information about how to add the custom preloader to your package.

4.2.4 Customization Options for Java Applets

Custom splash screens can be used with Java applets by passing in additional parameters when you deploy the applet. See Section 13.3.1, "Adding a Splash Screen" for information.

To add a custom progress bar to your applet, create a class that implements the DownloadServiceListener interface. See Displaying a Customized Loading Progress Indicator for instructions.

4.3 Helping Users Start the Application

In some cases, a user might have difficulty getting your application to run. For example, the following situations could cause an application to fail:

It is important to plan for users who experience problems, by either providing guidance to resolve the issue or having the application fail gracefully and explaining to the user why it cannot be resolved.

The following sections describe methods for handling some common issues.

4.3.1 No JRE

If the user does not have the JRE installed, then the application cannot start. The application package includes several hooks to improve the user experience in this case.

You can customize the default behavior described in the following sections. See Chapter 17, "Deployment in the Browser" for information about how to customize prompts to install the JRE, and error handling for web applications.

4.3.1.1 Standalone Launch

The main application JAR file includes a launcher program, which is used to detect the JRE. If the JRE is not found, then a dialog box is shown that explains where to get the JRE.

4.3.1.2 Launch with the Deployment Toolkit

If the application is embedded in a web page or launched from a browser using the Deployment Toolkit, which is described in Chapter 17, "Deployment in the Browser," then the Deployment Toolkit handles the detection of the JRE before trying to launch the application. If the JRE is missing, the Deployment Toolkit initiates installation by offering the user a link to the installer. By default, automatic download only occurs when the user launches an application using Java Web Start and has a recent version of the JRE.

4.3.2 Runtime Errors

An application can fail to launch due to various runtime errors or user mistakes, such as the absence of a network connection needed to load some of the application JAR files.

One of the most common errors is when the user does not grant permissions to the application. In that case, the application fails, and the user has to restart the application and then grant permissions to get it to run. In a case like this, it is helpful to explain to the user why the application failed and what the user must do to restart it successfully. By default, an error message is shown, either in a dialog box or inside the web page in the location where the application is embedded.

If the Deployment Toolkit is used, then the onDeployError handler can be used to display an error message in the application area in the web page. You can also consider including some instructions in the splash screen to alert users about granting permissions. For more information, see Chapter 17, "Deployment in the Browser."

For JavaFX applications, you can also include a custom preloader to get notifications about errors, unless the error occurs while launching the preloader. For more information about JavaFX preloaders and code examples, see Chapter 12, "Preloaders for JavaFX Applications."

Contents    Previous    Next

Oracle and/or its affiliates Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.
Contact Us