JavaFX Environment - JavaFX

What is JavaFX Environment?

From Java8 onwards, the JDK (Java Development kit) consists of JavaFX library in it. therefore, to run JavaFX applications, you really need to install Java8 or later version to your system.

Similarly to it, IDE’s like Eclipse and NetBeans provide help for JavaFX. This chapter teaches you a way to set the environment to run JavaFX applications in various ways.

Installing Java8

To start with, you will need to confirm whether there is Java installed on your system or not through starting the command prompt and typing the command “Java” in it.

If you haven’t installed Java to your system, the command prompt presentations the message shown inside the following screenshot.

JavaFX - Environment

Then install Java by way of following the steps given below.

Step 1 − go to the JavaSE Downloads page, click at the JDK Download button as highlighted in the following screenshot

JavaFX - Environment

Step 2 − On clicking the down load button, you will be redirected to the Java SE development kit 8 Downloads page. This page presents you links of JDK for various platforms.

Accept the license agreement and download the specified software by using clicking on its respective link.

for example, in case you are working on a windows 64-bit operating system you then want to download the JDK model highlighted inside the following screenshot.

JavaFX - Environment

On clicking the highlighted link, the Java8 development kit suitable for windows 64-bit operating system can be downloaded onto your device.

Step 3 − Run the downloaded binary executable record to begin the installation of JDK8.

JavaFX - Environment

Step 4 − Choose the Installation Directory.

JavaFX - Environment

Step 5 − On selecting the destination folder and clicking next, the JavaFX set up method begins displaying the progress bar as shown within the following screenshot.

JavaFX - Environment

Step 6 − Change the installation directory if needed, else keep the default ones and proceed further.

JavaFX - Environment

Step 7 − Finish the installation process by clicking the Close button as shown in the following screenshot.

JavaFX - Environment

Setting up the Path for Windows

After installing Java, you want to set the path variables. assume that you have installed Java in C:program Filesjavajdk1.8.0_91directory.

Now you may follow the steps that are given under −

  • Proper-click on 'My computer' and choose 'properties'.
  • Click on on the 'environment Variables' button below the 'advanced' tab.
  • Now, adjust the 'path' variable so that it also includes the path to the Java executable. as an example, if the path is presently set to 'C:WINDOWSSYSTEM32', then change your path to read 'C:WINDOWSSYSTEM32; C:program Filesjava jdk1.8.0_91bin'.

JavaFX - Environment

Setting NetBeans Environment of JavaFX

NetBeans8 presents inbuilt help for JavaFX. On installing this, you may create a JavaFX application with none additional plugins or JAR documents. To set up the NetBeans environment, you will want to observe the steps which are given below.

Step 1 − visit the NetBeans website NetBeans website and click the download button so that it will download the NetBeans software.

JavaFX - Environment

Step 2 − On clicking Download, you may get to the Downloads page of the NetBeans software, which presents NetBeans bundles for various Java applications. download the NetBeans software for JavaSE as shown inside the following screenshot.

JavaFX - Environment

Step 3 − On clicking this button, a file named netbeans-8.0-windows.exe may be downloaded onto your system. Run this file in order to install it. On running this file, a NetBeans installer will start as shown in the following screenshot.

configuring_installer

After completion of the configuration, you will see the Welcome Page of the installer.

Step 4 − Click the Next button and proceed with the installation.

JavaFX - Environment

Step 5 − the next window holds the NETBEANS IDE 8.0 license agreement. read it carefully and receive the agreement through checking the checkbox at “I accept the terms within the license agreement” after which click on the Next button.

JavaFX - Environment

Step 6 −In the next window, you may encounter the license agreement for Junit, receive it through selecting the radio button at “I accept the phrases inside the license agreement, set up JUnit” and click on next.

JavaFX - Environment

Step 7 − select the destination listing in which you need the Netbeans 8.0 to be set up. furthermore, you may additionally browse through the listing where Java development kit is installed on your system and click on the next button.

JavaFX - Environment

Step 8 − similarly, select the destination directory for Glassfish Server set up. Browse through the Java development kit listing (now for Glassfish Reference) and then click on next.

JavaFX - Environment

Step 9 − Check the Check for Updates box for automatic updates and click the Install button to start the installation.

JavaFX - Environment

Step 10 − This step starts the installation of NetBeans IDE 8.0 and it may take a while.

JavaFX - Environment

Step 11 − once the process is complete, click the end button to finish the installation.

Step 12 − when you release the NetBeans IDE, you may see the begin page as shown in the following screenshot.

JavaFX - Environment

Step 13 − In the file menu, select New Project… to open the New project wizard as shown in the following screenshot.

JavaFX - Environment

Step 14 − In the New Project wizard, select JavaFX and click on Next. It starts creating a new JavaFX Application for you.

JavaFX - Environment

Step 15 − Select the name of the project and place of the project in the NewJavaFX Application window and then click Finish. It creates a sample application with the given name.

project name

In this example, an application with a name javafxsample is created. within this application, the NetBeans IDE will generate a Java program with the name Javafxsample.java. As shown within the following screenshot, this application can be created inside NetBeans source packages → javafxsample.

JavaFX - Environment

Step 16 − Right-click on the file and select Run File to run this code as shown in the following screenshot.

JavaFX - Environment

This automatically created program carries the code which generates a simple JavaFX window having a button with the label Say ‘hello world’ in it. every time you click in this button, the string hello world can be displayed on the console as shown below.

JavaFX - Environment

Installing JavaFX in Eclipse

A plugin named e(fx)clipse is also available in JavaFX. you may use the following steps to set JavaFX in Eclipse. to start with, make sure that you have Eclipse to your system. If not, download and install Eclipse on your system.

Once Eclipse is installed, follow the steps given below to install e(fx)clipse for your system.

Step 1 − Open Eclipse in the help menu and select install New software… option as proven below.

JavaFX - Environment

Upon clicking, it will display the Available Software window, as shown in the following screenshot.

JavaFX - Environment

In the text box work with of this window, you want to provide the link of the plugin for the required software.

Step 2 − click the Add… button. provide the name of the plugin as e(fx)clipse. next, offer the following link as a location. http://download.eclipse.org/efxclipse/updates-released/2.3.0/site/

Step 3 − After specifying the name and area of the plugin, click the ok button, as highlighted in the following screenshot.

JavaFX - Environment

Step 4 − soon when you add the plugin, you may locate checkboxes for e(fx)clipse – install and e(fx)clipse – single components. test each these checkboxes and click the Add… button as shown in the following screenshot.

JavaFX - Environment

Step 5 − Next, open your Eclipse IDE. Click the File menu and select Project as shown in the following screenshot.

JavaFX - Environment

Step 6 − Then, you may get a window where you may see a listing of wizards provided through Eclipse to create a project. expand the JavaFX wizard, select JavaFX project and click the next button as shown in the following screenshot.

JavaFX - Environment

Step 7 − On clicking Next, a New Project Wizard opens. Here, you can type the required project name and click Finish.

project_name_and_click_finish

Step 8 − On clicking end, an application is created with the given call (sample). in the sub-package named application, a program with the call main.java is generated as shown below.

JavaFX - Environment

Step 9 − This automatically generated program contains the code to generate an empty JavaFX window. Right-click on this file, select Run As → Java Application as shown in the following screenshot.

JavaFX - Environment

On executing this application, it gives you an empty JavaFX window as shown below.

JavaFX - Environment

Note − We will discuss more about the code in the later chapters

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

JavaFX Topics