×

JavaFX Installation

In order to run JavaFX applications, we need to have eclipse and java installed on our machine.

Prerequisite:

Operating systemAny Operating system (Windows, Linux, Mac)
Memory requirementNo minimum requirement
Disk SpaceNo minimum requirement
JDK versionJDK 1.8 or above

For JavaFX, java is mandatory on the machine.

If you have already installed Java on your machine, you can verify the installation using the following commands:

  • For Windows:
  1. Open Command line.
  2. Type the command, C:\>java -version
  3. Press Enter key. It will display the available version of java.
  • For Linux:
  1. Open Command Terminal.
  2. Type the command, $ java-version.
  3. Press Enter key. It will display the available version of java.

If Java is not configured on your local machine follow the below steps to install java:

1. Install Java SDK from Oracle website, https://www.oracle.com/java/technologies/javase-downloads.html

2. Install JDK from Download files.

3. Follow the instruction given in Documentation to install setup.

4. Set Path for Java compiler

  • For Windows,

Insert ‘;%JAVA_HOME% bin’ at the end of system variable and path

  • For Linux,

Export PATH=$PATH:$JAVA_HOME/bin/

5. Set Java_Home variable to the path in your local machine where java is installed

  • For Windows,

Set Java_Home variable to C:\Program Files\Java\jdk1.8.0_171

  • For Linux,

Export JAVA_HOME=/usr/local/java-current

Installing Eclipse IDE:

1. Visit the link https://www.eclipse.org/downloads/ and download the latest version of the eclipse available on the site.

2. After clicking on the download button, it will download the installer. After successful download click on the exe file, prompt will appear, click on the Run button.

3. It will show various software suits, choose the right one you want to install.

JavaFX Installation

4. We will choose Eclipse IDE for Java Developers. The next screen will appear. Choose the path and click on the Install button.

JavaFX Installation

5. Accept the Eclipse foundation software user agreement by clicking on the Accept button and then in the next window click the Launch button to start Eclipse IDE.

6. Select the workspace directory by clicking on the browse button and once selected click on the Launch button.

JavaFX Installation

Installing JavaFX:

1. Open the Eclipse IDE installed on your machine, click on the Help, then select the Eclipse Marketplace from the drop-down menu.

JavaFX Installation

2. Then in Eclipse Marketplace type javafx in the searchbox and click the enter button.

JavaFX Installation

3. It will show e(fx), install it.

4. Once it is successfully installed you have to restart the eclipse to reflect the changes done.

5. Click on File then select New, Choose Project option, and select JavaFX and under dropdown of it click it on JavaFX project.

JavaFX Installation

6. Click on the Next button and Enter the name of the project let us say “JavaFx" and click on the Finish button.

7. Then you have to download JavaFX from the site https://gluonhq.com/products/javafx/.

8. It will download the zip file, you have to extract it into any folder.

9. Right click on the project and click on Properties, choose the Java Build Path option, and then click on the Libraries tab.

JavaFX Installation

10. Then choose JavaFX SDK, click on the add external JARs from the right menu. Then choose all the .jar files available in the downloaded folder in the lib directory. Click on open then select Apply then Apply and Close.

JavaFX Installation

11. Right click on the project select Run As choose Run Configuration then in arguments tab under VM arguments enter the following text:

        --module-path /path/to/JavaFX/lib  --add-modules=javafx.controls,javafx.fxml

JavaFX Installation

12. Also, you have to uncheck the box saying "Use the – XstartOnFirstThread..”

13. Then at last click Apply and Run.

After successful installation create a new java file in the project by right clicking on the src-> new-> class. Then enter the Java class name and package name if you want.

Java Code:

import javafx.application.Application;  
import javafx.scene.Scene;  
import javafx.scene.control.Button;  
import javafx.stage.Stage;  
import javafx.scene.layout.StackPane;  


public class First extends Application
{  
  
    @Override  
    public void start (Stage primaryStage) throws Exception 
   {  
        Button btn1 = new Button("Welcome");  
        StackPane root = new StackPane();  
        root.getChildren().add(btn1);  
        Scene scene=new Scene (root,600,400);      
        primaryStage.setTitle (" Welcome to JavaFX ");  
        primaryStage.setScene (scene);  
        primaryStage.show();  
    }  
    public static void main (String[] args)  
    {  
        launch(args);  
    }   
}  

In order to run the application, Right click on the java file select Run as, and click on Java Applications. It will show one frame with the title, Welcome to JavaFX, and welcome button added on it.

JavaFX Installation

Related Topics

JavaFX Shadow

In the JavaFX application, in order to apply various Shadow effect from a single source, we use this class. It has the ability to create the shadow of the given...

3 minutes read.

JavaFX Parallel Transition

In the JavaFX application, in order to generate the parallel transition, we have to apply parallel transition on any particular shape. It has the ability to execute multiple transactions parallelly....

4 minutes read.

JavaFX Reflection

In the JavaFX application, in order to apply various reflection effect, we use this class. It has the ability to create the reflection of the given object. This effect adds...

4 minutes read.

JavaFX Motion Blur

In the JavaFX application, in order to apply various Motion blur effect, we use Motion Blur class. It has the ability to apply the Motion blur effect on the given...

4 minutes read.

JavaFX Lighting

In the JavaFX application, in order to apply various Lighting effect from a single source, we use this class. It has the ability to lighten a node from a given...

4 minutes read.

JavaFX ProgressBar

In the JavaFX application, in order to show the progress of work ProgressBar is used. It shows how much work is done. In order to use ProgressBar in JavaFX, javafx.scene.control.ProgressBar...

4 minutes read.

JavaFX UI Controls

We can make an advanced graphical user interface (GUI) for the JavaFX application using UI Controls and layouts. Various UI elements can be used b the programmer in their application...

3 minutes read.

JavaFX Line Chart

In the JavaFX application, in order to create a Line Chart, LineChart class is used. The LineChart allows us to plot markers point according to the entities on number axes....

4 minutes read.

JavaFX Ellipse

In the JavaFX application, in order to draw an Ellipse, the Ellipse class is used. The Ellipse allows us to join any points in the space to draw the unique...

7 minutes read.

JavaFX Menu

In the JavaFX application, in order to create a menu, menu items, and menu bar, Menu, MenuItem, and MenuBar class is used. The menu allows us to choose options among...

4 minutes read.

JavaFX Architecture

JavaFX architecture consists of many built-in components such as JavaFX public API, Scene Graph, Quantum Toolkit, Prism, Glass windowing toolkit, web view, media engines. These components help to develop rich...

3 minutes read.

JavaFX Path Transition

In the JavaFX application, in order to generate the path transition, we have to apply path transition on any particular shape. It has the ability to traverse the given shape...

3 minutes read.

JavaFX Bar Chart

In the JavaFX application, in order to create Bar Chart, the BarChart class is used. The Bar Chart allows us to plot data along different bars to show the scales...

4 minutes read.

JavaFX Translate Transition

In the JavaFX application, in order to generate the translate transition, we have to apply translate transition on any particular shape. It has the ability to translate the shape along...

3 minutes read.

JavaFX Inline Styles

In the JavaFX application, in order to apply various Inline css effect we will use the various css classes available in the JavaFX. It is used to apply the various...

4 minutes read.

JavaFX Arc

In the JavaFX application, in order to draw an arc, the Arc class is used. The Arc allows us to join any points in the space. All methods needed for...

5 minutes read.

JavaFX Light Point

In the JavaFX application, in order to apply various LightPoint effect from a single source, we use this class. It has the ability to apply light from a single source...

4 minutes read.

JavaFX Scatter Chart

In the JavaFX application, in order to create Scatter Chart, the ScatterChart class is used. The Scatter Chart allows us to plot data along the x and y axis of...

4 minutes read.

JavaFX GridPane

In the JavaFX application, in order to set Grid Pane as a layout, the GridPane class is used. The GridPane layout allows us to arrange the components in the form...

4 minutes read.

JavaFX HyperLink

In the JavaFX application, in order to access and use webpages, hyperlinks are used. In HTML anchor tags are used in the same way in JavaFX hyperlinks are used. To...

4 minutes read.