Home / Java / Install JavaFX on Ubuntu

Install JavaFX on Ubuntu

What is JavaFX ?

JavaFX is a library that comes to replace the swing, JavaFX is facilitates the programmer to design eye catching Application using Java with minimal coding. JavaFX uses the Model View Controller (MVC) approach. JavaFX supports the use of CSS and FXML to build graphical user interface.

Before the installation begins you much checkout How to install eclipse on ubuntu

JavaFX does not comes pre-built with the latest version of java jdk so we have to install it manually. To install JavaFX you must ensure that your JAVA_HOME variable is set properly.  To check JAVA_HOME is set properly type the command.

screenshot-from-2017-05-25-22-18-52

In my case JAVA_HOME is set /usr/lib/jvm/java-8-openjdk-amd64/

Let us begins the installation of javafx.

This will install JavaFX on your system and provides the following jar files to OpenJDK installation on your system.

Now JavaFX has been installed on our system we have to set it up with our eclipse IDE.

Setting up JavaFX on Eclipse IDE

First, Create a new project by navigating to File->New->Java Project

New Java Project

Type the name of your project and hit finish button. This will create a new Project in your workspace.

Right click on the project you created for the JavaFX go to build path and Click User Libraries. A new Window will appear select User Libraries and click on next button. After clicking next click the User Libraries button on the right side of the window.

Adding User Library

A new window will appear click on New button on the right side and name the new library once new library is created select it and hit the Add External JARs button navigate to the path which i mentioned above and select jfxrt.jar file and click ok.

Congratulations !! JavaFX has been imported to your project now create a new java class in your project and paste the following code to check whether JavaFX is working or not.

 

Share This:

About Hasnain