Friday, April 23, 2010

Now Build and Run Interactive Contents for TV

TV Software Development Kit Getting Started Guide

Introduction

This guide describes how to install and set up the JavaFX TV Software Development Kit (JavaFX TV SDK). The JavaFX TV SDK is available within the NetBeans IDE, and also as a command line version. The installation procedures for these two versions are presented in Installation.

Note: Normally, as a developer you will want to work with either the NetBeans or the command line version.

Overview
The JavaFX TV SDK provides an environment for developing and compiling JavaFX applications, and for demonstrating them in an emulated television environment. This guide gets you started compiling and running example JavaFX applications.



Prerequisites

This release requires the Microsoft Windows XP operating system. (Some testing has been successful on later versions of Windows.) Prior to installing the JavaFX TV SDK, the following tools should be installed on your Windows workstation.

Java Development Kit
Version 1.6 of the Java Development Kit (JDK) is required for running the JavaFX TV SDK. Update 14 version (or newer) of JDK 1.6 is recommended. If needed, you can download and install the latest version of the JDK from this link: (http://java.sun.com/javase/downloads/index.jsp) It is not necessary to download a JDK 6 update bundled with JavaFX, since the JavaFX SDK is contained in the JavaFX TV SDK release.

Uninstall Prior Versions of JavaFX TV SDK
If your workstation has a prior installation of the command line version of the JavaFX TV SDK, it must be uninstalled before any new install. The new JavaFX TV SDK installer will detect a prior installation when you launch it, and will give you the option to uninstall.

Installation

The JavaFX TV SDK is available as a NetBeans plugin, and also as a command line version. The installation procedures for these two versions are presented here.

Note: Be sure that all the necessary prerequisites are installed on your Windows development workstation. Refer toPrerequisites.

To Install the NetBeans IDE Including the JavaFX TV SDK
Simply run the installer (netbeans-javafx-windows.exe) included with this release. A complete NetBeans IDE will be installed on your Windows workstation, including the Java platforms for JavaFX 1.3 and JavaFX TV. This will enable you to compile and run JavaFX TV sample applications, and to create your own JavaFX TV applications. The JavaFX TV SDK also includes an emulator, so you can run a compiled JavaFX TV application and see how it will appear on a TV screen.

About Prior NetBeans Installations
It is possible to install the NetBeans IDE included with this release and retain your prior NetBeans installations, if any. Or, you may prefer to uninstall your exiting NetBeans installations before installing this NetBeans SDK.

Installing the JavaFX TV SDK as a NetBeans IDE

  1. Double-click the installer (netbeans-javafx-windows.exe). You will see the welcome screen:


  2. Click the Next button. You will be presented with the license agreement.


  3. Click the checkbox to accept the terms of the license, then click Next. The next windows shows a default directory to install the IDE. You can select the default or enter or browse to a different location. It also shows the directory of the JDK found by the installer. If desired, you can point to a different JDK installed on your system.


  4. Click Next when the directories are set up correctly. The next screen summarizes the parameters of the installation and has an Install button you can click to begin the install.


  5. The next window shows the progress bar for the installation, which will take several minutes. You can click to cancel if need be.


  6. The final window indicates that setup is complete. You are given the option to provide anonymous usage data to the NetBeans project. Click Finish to dismiss the installer.

Installing the Command Line JavaFX TV SDK
Follow these steps to install the command line version JavaFX TV SDK (along with the rest of the JavaFX SDK).

  1. Download the JavaFX TV SDK installer (javafx_sdk-1_3-windows-i586.exe) to a convenient temporary location, such as C:\installers.


  2. Run the installer. A wizard launches with a welcome screen.


  3. Click Next to see the license agreement, which you must accept to continue.


  4. You will be presented with the default location for the install.


  5. Click Next to accept the default location.


  6. When you see the Ready to Install screen, click Install to begin the installation.


    The installation will take a few minutes, during which you will see this screen:


  7. Click the Finish button to exit the installer.
Summary
The JavaFX TV SDK is now ready for use. See Sample Applications for instructions on compiling and running example JavaFX applications.



Write Your Own JavaFX TV Application in NetBeans

It is easy to begin to develop your own JavaFX TV application in the NetBeans IDE. This chapter takes you through the steps.

Create a New JavaFX Application in NetBeans
Follow these steps to create a new JavaFX TV project in NetBeans:

  1. As for creating any new project in the NetBeans IDE, the first step is to select New Project from the File menu:


  2. In the New Project window, select JavaFX from the list of Categories. Click Next.


  3. In the next window, fill in the name for the project in the top field. The default Project Location is filled in as a directory under the Windows user's Documents directory. You can change this if you wish. The Project Folder is automatically set to a folder named according to the Project Name, directly under the Project Location.

    By default, the click boxes on this screen are on, to set this as your main NetBeans project, and to automatically create the main Java class for the project. You can also unclick these boxes if desired.


  4. When you click Finish, the project is created in NetBeans. The tree of project files is shown under the Projects tab at the upper left of the IDE. The main window in the center of the IDE contains the stub code for the main Java class.


  5. Right-click the root of the JavaFXApplication project in the Projects pane at the upper left. Select Properties, the last choice in the pop-up menu.


  6. The Project Properties window comes up. Click the Run category in the left pane. Click the Run in TV Emulator radio button.


  7. In the same Project Properties window, select the Application category in the left pane. Click the Draggable Applet click box.


  8. Build the stub project. Right-click the root of the JavaFXApplication project in the Projects pane at the upper left. Select Build Project from the pop-up menu.


  9. The Java code is built and compiled. The session log is seen in the bottom pane of the IDE. Next, run the compiled stub. Right-click the root of the JavaFXApplication project in the Projects pane at the upper left. Select Run from the pop-up menu.


  10. A small emulator window will pop up.


  11. Now you can use the stub code as a basis to develop your own JavaFX TV application. You can write code directly or make use of the palette of shapes, components, controls and other JavaFX constructs to automatically generate JavaFX code for your application.

Sample Application

Included with this SDK are example JavaFX applications that you can compile and run on the emulator. You can work with sample applications in NetBeans and from the command line, depending on which version of the SDK you are using. This chapter shows how to work with sample applications in NetBeans and from the command line. In this case, the SDK is command line only. Thus, the chapter shows how to compile and run a sample application using the command line.

Work with a JavaFX TV Application in NetBeans
Sample JavaFX programs are available at http://javafx.com/samples/. Some of these scripts are optimized for TV. These have a TV icon, which is a larger screen, to the right of the icon for a computer screen.

If you click on the graphic representing the sample, you will go to a page dedicated to that sample. There will be a button on that page labeled Download Source Code. It's a good idea to download a few TV sample scripts for experimentation.

Follow these steps to open a sample program as a project in NetBeans.

  1. On the NetBeans IDE, select Open Project from the File menu. Navigate to where you downloaded and unpacked the samples. For example, if the samples are located in your Windows Downloads folder:


  2. For example, select the Brickbreaker application and click Open Project. Click Accept.


  3. Right-click the root of the Brickbreaker project in the Projects pane at the upper left. Select Properties, the last choice in the pop-up menu.


  4. The Project Properties window comes up. Click the Run category in the left pane. Click the Run in TV Emulator radio button.


  5. In the same Project Properties window, select the Application category in the left pane. Click the Draggable Applet click box. Click OK.


  6. Build the sample project. Right-click the root of the Brickbreaker project in the Projects pane at the upper left. Select Build Project from the pop-up menu.


  7. The Java code for the Brickbreaker project is built and compiled. The session log is seen in the bottom pane of the IDE. Next, run the compiled sample. Right-click the root of the Brickbreaker project in the Projects pane at the upper left. Select Run from the pop-up menu.


  8. The Brickbreaker application runs in the TV emulator You can play this game using the mouse control. On a set-top box deployment, this game would be played using the TV remote control.

Compile and Run a JavaFX Application Using the Command Line
Follow these steps to compile a sample program. This procedure uses command lines in the Windows command shell. The example compiled here is called Mosaic. Similar steps are followed to compile any of the other JavaFX TV samples.

  1. Unpack the samples bundle in a convenient directory. For example,
    D:\JavaFX-TV-Samples

  2. Launch a new Windows command shell. Verify that the SDK_HOME variable is correctly set:
    > echo %SDK_HOME%
    "C:\Program Files\JavaFX\javafx-sdk1.3"


    This should be set to the installation path you selected when installing the SDK. For example,

    C:\Program Files\JavaFX\javafx-sdk1.3

    Note - Use the Windows System control panel, Advanced tab to set an environment variable persistently. Or, to set it with the setx command, see the instructions in Using the Windows setx() Command.


  3. Verify that the JavaFX SDK bin directory is in your PATH.
    > echo %PATH%

    The PATH should include this directory, which contain javafx and javafxpackager:

    C:\Program Files\JavaFX\javafx-sdk1.3\bin

    If not correctly defined, you must change your PATH environment variable as follows:
    > set PATH="C:\Program Files\JavaFX\javafx-sdk1.3\bin";%PATH%

    Again, to set up PATH persistently, use the control panel or the setx command.


  4. Change directory to the directory where you unpacked the samples.
    > cd D:\JavaFX-TV-Samples


  5. If you want to work on a different volume, enter the volume letter to change your command prompt to point to that volume.
    > D:
    D:\JavaFX-TV-Samples>


  6. Change to the directory containing the Mosaic example JavaFX programs.
    D:\JavaFX-TV-Samples>cd Mosaic
    D:\JavaFX-TV-Samples\Mosaic>


  7. Compile, build and package this application using the javafxpackager.
    > javafxpackager -p tv -src src -appname Mosaic -appClass mosaic.Main

    (This is one long command line, even though it wraps on this page.) You will see the result under the dist directory:
    > dir dist\*.jar
    Mosaic.jar


  8. Use this command to run the sample application in the emulator:
    > javafx -profile tv -jar .\dist\Mosaic.jar

    A colorful window appears in the TV emulator:


  9. Type in search text to find a group of images. For example, search for "bird." Press Enter or click the Search button.


  10. An array of bird images will be displayed!

Setting Environment Variables Persistently in Windows

In Microsoft Windows, you can use a GUI control to persistently set up environment variables. Then the variable will be available and active in any new command shell. Sometimes you may find it more convenient to set variable persistently from a command within a Windows shell. You can accomplish this using the setx() command described in this topic. A variable set up this way will be available in any new Windows command shell you might launch.

Using the Windows setx() Command
For example you can persistently define the variable SDK_HOME in the Windows command shell as follows:
> setx SDK_HOME "C:\Program Files\JavaFX\javafx-sdk1.3"

Note: You must launch a new command shell to use the newly set environment variable.

The Windows XP Service Pack 2 Support Tools are available for download at
http://www.microsoft.com/downloads/details.aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38&displaylang=en

The setx tool is built in to Vista and Windows 7.

No comments:

Post a Comment

🎧 EchoVerseMusick: Where Vibes Speak Louder Than Faces

🎧 EchoVerseMusick: Where Vibes Speak Louder Than Faces Welcome to EchoVerseMusick — a faceless fusion of sound, soul, and scenery. If y...