5 Easy Steps on How to Build and Deploy Android Apps Using JavaFX

Java has been rated as one of the best programming language to develop software projects, irrespective of devices. It is versatile, means the program can be run on different machines including Macintosh, Windows and Unix. This makes it stand out from other languages. Check the TIOBE Index for March 2015.

Java, a client-side programming language, the platform has been developed with an aim to serve a software environment for embedded devices.

Due to lucrative server market, Java on the client-side has been neglected and is given less attention. To compete in such ambitious market, Java has now packed with new and improved client-side component, JavaFX.

What is JavaFX?

JavaFX, a new Java client component and an integral part of the Java SE environment allow developers to design, test, debug and deploy rich client application that can run across a variety of devices. With this new component, you can now build applications for desktops, tablets, mobile and other embedded devices.

Emergence of JavaFX

AWT(Abstract Window Toolkit) creates a great user interface for Java platforms. For achieving a more sophisticated set of GUI components, there came a high-level toolkit called Swing which is partially based on AWT. Today, there is a need of responsive UI with a performance toolkit. However, you need to look at another option because the design and principles of these toolkits will no longer match today’s hardware and software capabilities. The only option is : JavaFX. Its key principle is to leverage hardware as much as possible. It provides the standard GUI library for Java SE.

JavaFX Application

Being the JavaFX library written as Java API, JavaFX application can refer to any API from any Java library. JavaFX application can be customized as follows:

1. Developers can concentrate solely on coding as CSS (Cascading Style Sheets) separate appearance and style from implementation.

2. You can separate the user interface (UI) and back end logic, by developing presentation aspects of the UI in the FXML scripting language and use Java code for the application logic.

3. JavaFX Scene Builder will help you to design UIs without writing code.

JavaFX is fully integrated with the Java SE 7 Runtime Environment (JRE) and the Java Development Kit (JDK). The application can be complied to to JDK 7 and so it runs on all major platforms.

Availability :

JavaFX is must not only on desktop applications, but also on IOS and Android after realization the massive increase on Smart-phones. 3 versions of the same application in 3 languages are quite expensive, but with JavaFX the same application can be deployed on all these platforms.

Now, let focus on how to run the existing JavaFX application on Android.

Step 1. Install the Android SDK and JavaFX-Android SDK.

a) Android SDK – Download it here!

What it provides?

– Android.jar API

– Tools to convert Java class files into Dalvik bytecode.

– Tools to communicate with Android devices and this transfer application to devices and inspecting logs.

After download, you can set the ANDROID_SDK environment variable to the downloaded adt-bundle-xxx/sdk (xxx- depends on the version of your system).

b) JavaFX Android SDK – Download it here

What it provides?

– JavaFX implementation that runs on Android.

– Tools to build Android packages and sample application of JavaFX

After download, you will need Ant to build an apk file.

Step 2) Create JavaFX Application!

Creating JavaFX application on Android is same as creating on desktop systems. Use your favorite IDE and JavaFX-Android SDK tools to create JavaFX applications. Here, there is no need of particular JavaFX application launcher or any configuration.

Always stick to the plat-form independent code and make use of Android platform services for required functionality to your application. (Add the dependency on android.jar and refer to contained class.)

Check how to create a JavaFX application using sample application!

1. Dalvik_SDK that you downloaded on step. 1, do the following:

cd to the samples/HelloWorld

2. Package your application as jar

– First, do the cd to Dalvik_SDK/samples/HelloWorld/javafx

– Build the application using ./gradlew on linux and MacOS or gradlew.bat on Windows. This creates a jar file (HelloWorld.jar)


– Your application should not be used on

any Android specific functionalities. For eg: Desktop systems.

– While creating Android layout, be concerned about smaller UI footprints, as handheld devices have smaller footprints.

Step 3) Generate Android Project based on your JavaFX application

Use JavaFX-Android SDK that contains build scripts “convertJavaFXToAndroid.sh” embedded within “samples” directory. This will create an Android project, containing files and scripts to generate Android packages.

If you are building your own project, you need to provide following parameters:

– Location of Android SDK

– JavaFX-Android SDK

– Location of JavaFX applications

– Name of main class file

Lastly, make one modification to make the file work : Set ANDROID_SDK on top and point it to your system ANDROID_SDK, downloaded on step1.

Place gradle related files in one directory and then copy the directory from sample directory to your JavaFX project root. Make necessary modification to the convertJavaFXToAndroid.sh script and finally call that script.

You will find your Android Project under samples/HelloWorld/javafx/build.

Step4) Create Android Packages Using Ant Build System.

The “build” that you generated in Step 3 contains a build.xml file. Create Android debug packages, that can be used on Android devices by calling:

cd to the build directory and call “ant debug”.

Now sent .apk files on device by calling:

$ANDROID_SDK/platform-tools/adb -r install /path/to/the.apk

Step5) Upload JavaFX Application – App Store Deployment.

You can upload JavaFX application in the same manner you upload Android application. But the uploading process is long and it has been under progress due to following reasons:

– Writing JavaFX application and submitting to Play Store has a long path.

– Different types of systems are used that makes the process more lengthy.

For eg: JavaFX application using Maven needs 3 system:

a) Maven for your application development

b) Gradle for creating the Android Project

c) Ant for building the Android package.

However, you can fix these issues and there are number of ways that can improve the whole process. Check it below:

1. Android has chosen Gradle as one of the preferred building environment. You can easily compile JavaFX application

2. JavaFXPackager, provides bundles for different target environment. It is recommended to integrate this with the JavaFX- Android SDK.

3. Integrate JavaFX support with IDE’s that contain plugins for Android development.

4. JavaFX end-to-end toolset will allow developers to instantly write JavaFX application and upload to the Play Store.

For more understanding, you can check this video.

What’s New about JavaFX?

– Oracle plans for open-source JavaFX on IOS and Android.

– Biggest upadate to JavaFX : Release of JDK 8 Update 40. (JDK8U40)

– Improve support for third party control with Scene Builder. Download it here.

If you have any query or even want to give any suggestion, then let us know about it in comments below.


Chirag Leuva Co-Founder and CMO

Mr. Chirag Leuva is the working director of the company and takes care of business development activity, marketing initiatives, and client relationship. His enthusiasm towards helping start-ups to reach heights of success is noteworthy. He started taking initiative to expand the business since 2009. His passion involves public speaking and creating effective business strategies. As a logical and intuitive person, he works toward achieving business objectives efficiently.
“A calculated risk is what defines a successful business!”

Comments are closed.