Configuring the Application for Execution and Deployment
In this section, you configure the Spring Animation project to execute from within the IDE by using each of the four available execution models.
Using the Standard Execution Model
By default, a new JavaFX project created in the IDE is set to execute as a stand-alone application by using the Standard Execution model, which means it is executed stand-alone with the javafx command. If you have changed the default execution model, use the steps in this section to configure the Spring Animation
sample to use this Standard Execution model again.
- In the Projects window, right-click the Spring Animation project's root node and select Properties.
- Select the Run category in the Project Properties dialog box.
- Notice that the Main Class field is already set to
custominterpolator.SpringDemo. Leave this default setting. - Select the Standard Execution as the Application Execution Model, if it is not yet selected, and click OK.
- In the Projects window, right-click the Spring Animation project's root node and choose Build Project.
After a project is built, thebuildanddistfolders are added to theNB_PROJECT_HOMEproject folder. All of the project's sources are compiled into.classfiles and placed into the newNB_PROJECT_HOME/buildfolder. A newSpringAnimation.JARfile containing the project is created inside the newNB_PROJECT_HOME/distfolder. If other libraries were specified for the project, alibfolder is created in thedistfolder and the other libraries are copied intodist/libfolder. The manifest file in the JAR is updated to include entries that designate main class and any libraries that are on the project's classpath. - In the Projects window, right-click the Spring Animation project's root node and select Run Project.
The IDE builds the executable files for the application and a separate window appears, running the application.
Using the Java Web Start Execution Model
Java Web Start is a mechanism that enables users to start a Java based application directly from a web browser. The application is deployed to the client and executed outside the scope of the browser. After it is deployed, the application does not need to be downloaded again, and it can automatically download updates on startup without requiring the user to repeat the whole installation process.
When you execute a JavaFX application from the IDE by using this model, the IDE executes it locally. To package the Spring Animation sample for Java Web Start deployment, perform the following steps.
- If necessary, right-click the SpringAnimation project's root node and select Clean Project in the Projects window.
This action removes the files that were generated from any previous builds, including the one in the previous section of this tutorial. - Right-click the project's root node again, and select Properties.
- (Optional) Set the properties to self-sign and compress the JAR files.
Though optional for this sample application, this step is necessary if your application requires access to any secured computer resources or secured Java classes and methods.
- In the Project Properties dialog, select the Application category.
- Under the Web Start Specific Properties section, select the Self Signed JAR files and the Pack200 Compression checkboxes.
The Pack200 is a compression utility that is designed for compressing JAR files.
- In the Project Properties dialog, select the Application category.
- In the Categories pane, select the Run category and then on the right pane, select Web Start Execution as the execution model.
- Click OK.
- In the Projects window, right-click the Spring Animation project's root node and choose Run Project.
The IDE builds the project and thebuildanddistfolders are added to theNB_PROJECT_HOMEproject folder. All of the project's sources are compiled into.classfiles and placed into the newNB_PROJECT_HOME/buildfolder. A newSpringAnimation.JARfile containing the project is created inside the newNB_PROJECT_HOME/distfolder. TheSpringAnimation.JNLPdescriptor file is also created and will be used when executing the application by using Java Web Start. If you performed the optional step 3, theSpringAnimation.jar.pack.gzfile is also created.
After the executable files are created, a Java Web Start window appears with a progress bar to show the application download progress..
- Continue through the digital signature or certificate verification dialog boxes by clicking Trust or Run, depending on the platform that you are using.
- When the application is successfully started, a separate window appears, running the application.
Using the Run in Browser Execution Model
In this execution model, an HTML file is generated to invoke the sample application from the default browser that is set for the IDE's use.
- Right-click the SpringAnimation project's root node and select Clean Project in the Projects window.
This action removes the files that were generated from any previous builds, including the one in the previous sections of this tutorial. - Right-click the SpringAnimation project's root node again and select Properties.
- In Project Properties dialog box, select the Application category.
- Under the Applet Specific Properties section, set the desired width and height to use for your applet.
The default for the SpringAnimation project is 240 pixels by 320 pixels. - (Optional) Select the Draggable Applet checkbox, if desired.
This option enables your application to be dragged from the browser to the desktop. The default browser used by the IDE has to have installed the minimum version of the Java Runtime Environment (JRE) that supports this feature (minimum version of JRE 6 update 10). - In the Categories pane, select the Run category.
- Select the Run in Browser execution model and click OK.
- In the Projects window, right-click the project's root node again and select Run Project.
The IDE builds the project, and thebuildanddistfolders are added to theNB_PROJECT_HOMEproject folder. All of the project's sources are compiled into.classfiles and placed into the newNB_PROJECT_HOME/buildfolder. A newSpringAnimation.JARfile andSpringAnimation.htmlfile are created inside the newNB_PROJECT_HOME/distfolder.
The IDE runs the SpringAnimation application by using the default browser set for the IDE to use.
Using the Run in Mobile Emulator Execution Model
The JavaFX Mobile Emulator is a mobile phone simulation tool and is currently available on the Microsoft Windows platform only. The emulator runs the compiled classes that are built by the IDE. For a JavaFX application to be compatible with running in the mobile emulator, the Common and Mobile APIs must be used. You must have Apple Quicktime 7.5.5 minimum installed on your system to run multimedia in the emulator.
Use the following steps to prepare the Spring Animation tool for execution on the mobile emulator.
- Right-click the SpringAnimation project's root node and select Clean Project in the Projects window.
This action removes the files that were generated from any previous builds, including the one in the previous sections of this tutorial. - In the Projects window, right-click the SpringAnimation project's root node and select Properties.
- In Project Properties dialog box, select the Run category.
- Select the Run in Mobile Emulator execution model and click OK.
- In the Projects window, right-click the project's root node again and select Run Project.
The IDE builds the project, and thebuildanddistfolders are added to theNB_PROJECT_HOMEproject folder. All of the project's sources are compiled into.classfiles and placed into the newNB_PROJECT_HOME/buildfolder. The newSpringAnimation.JARandSpringAnimation.jadfiles are created inside the newNB_PROJECT_HOME/distfolder. Java Application Descriptor (JAD) files describe the MIDlets or Java ME applications that are distributed as JAR files.
The IDE starts the JavaFX SDK Device Manager and the Mobile Emulator is started.
- If you agree, permit the application to continue executing, if you are prompted.
When executing the application behind a firewall, you are prompted a few times for permission to continue with the execution.
After the application has been installed, the emulator continues with the execution of the SpringAnimation application on the mobile emulator.
Cindy Castillo
Technical Writer, Oracle Corporation