Pro Java 9 Games Development Leveraging the JavaFX APIs

(Michael S) #1

Chapter 6 ■ Setting Up YoUr Java 9 iDe: an introDUCtion to netBeanS 9


A JAR file does not contain your actual JavaFX code but rather a compressed, encrypted, “Java
bytestream” version of your application, which the JRE can execute and run (like NetBeans 9 is doing now).
The “path” that is attached to the front of the JavaFXGame.jar file tells you where NetBeans 9 has compiled
your JAR file to on your HDD and where it is accessing it from currently to be able to run it. On my system,
this location was as follows:


C:\Users\Walls\Documents\NetBeansProjects\JavaFXGame\dist\run1381287366\JavaFXGame.jar


Let’s take a look at some of the other Output tab text in order to see what NetBeans did to get to the
point where it could run the JAR file for the project. First the Ant Build System is invoked using ant -f
source-path jfxsarun, and since the Java executable is not found in the JDK, it finds one in the runtime
instead. It then initializes (init:) and in the JAR Dependencies (deps-jar:) section creates a \build directory
and updates the built-jar-properties file. It then creates the \build\classes, \build\empty, and \build\
generated-sources\ap-source-output directories. Ant will then compile the project to the \build\classes
directory, and if the build (compile) is successful (error-free), Ant will create the \dist distribution folder
and deposit your JAR file there.
Ant then uses the JavaFX Ant API to launch ant-javafx.jar and deploys the JavaFX API, copying the
JavaFX JAR files into a \dist\run1381287366 folder. Finally, Ant runs the JavaFX project using jfx-project-
run:, executing the Java 9 and JavaFX code, which is the equivalent of running (and testing) it, as shown on
top of the NetBeans 9 IDE.
Ant is the “build engine” or build tool that creates your JAR file, and there are other build engines, such
as Maven and Gradle, that can also be used in NetBeans if you like because, as you now know, NetBeans is
extensible. Since Ant goes back the furthest and is the “legacy” build system, we will be using that during the
course of this book.


Summary


In this sixth chapter we took a look at the NetBeans 9 “official” Integrated Development Environment (IDE)
that you will use as the foundation and primary tool for your Java 9 Game Development work process. This is
because this IDE is where your Java 9 (and JavaFX API) code is written, compiled, run, tested, and debugged,
as well as where your new media (imagery, audio, video, 3D geometry, textures, fonts, shapes, etc.) assets are
stored and referenced using your NetBeansProject folder and its subfolders. We started by taking a high-
level view of NetBeans 9 and its new features such as Java 9 module support, as well as some recent legacy
features, and added in NetBeans 8, 8.1, and 8.2. These are the powerful features that make NetBeans 9.0
the official IDE for Java 9. These features will help programmers to develop Pro Java 9 game code quickly,
efficiently, and effectively, the first time. After this overview, we created a Pro Java 9 Game Project using the
New Project series of dialogs and the JavaFX Application bootstrap Java code template.
We went through the New ➤ Java Application series of dialogs and created a JavaFX framework for
our game, which will allow us to use new media assets. After that we took a look at how to compile (build
and run) the app using NetBeans 9 and then at how to run an application using NetBeans. We looked at the
Output tab and how this is used for compiler output and looked at the Ant build process to see what it does
to combine Java 9 with its JavaFX APIs.
In the next chapter, we are going to take a tour of the JavaFX programming language, a “JavaFX primer,”
if you will, and examine the JavaFX code that is in your JavaFX bootstrap application (shown in Figure 6-7)
so that you will know what this JavaFX code is doing. We will also look at the modular components of the
comprehensive JavaFX API.

Free download pdf