Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Running JavaFX on a server

1 min read

JavaFX on the server???

Java FX on a Server? Is it the Future?

JavaFX is heavily promoted as a desktop technology to replace Swing. So it might seem slightly strange to suggest running it on a server. But JavaFX also offers a replacement for Graphics2D. We use Graphics2D extensively for creating images from PDF data. One of the popular uses for our Java PDF library is to convert PDF files to images on the server. Currently we use Graphics2D for this. So can you use JavaFX on your server, and how well does it run?

Reasons to use JavaFX in place of Graphics2D

We have found 3 reasons to use JavaFX:-

1. More Functionality. JavaFX offers a much more polished set of functions that Graphics2D. As an example, General shapes and paths have much more functionality in JavaFX and you do not need to convert them to Areas,

2. Less code. We have found that our JavaFX implementations have much less code than Graphics2D. This is partly because the API is better designed and partly because JavaFX has more functionality. My colleague Simon has a really interesting blog article on how much simpler blend modes are in JavaFX.

3. The Future. Swing will continue to be around but is unlikely to see any improvements. JavaFX is where all the action is and work is happening to make it run on as many platforms as possible.

An actual code example

Here is a simple code skeleton example. We recommend you run JavaFX on Java8.

import javafx.application.Application;
import javafx.application.Platform;
import javafx.stage.Stage;
import org.jpedal.PdfDecoderFX;
* Runs on the server as well
*/public class ServerFXExample extends Application{

public void start(Stage stage) throws Exception {

//Your JavaFX code


* Main method to call on server
*/public static void main(String[] args) {



Some ‘caveats’

We have found only 2 real issues with JavaFX (which are more than out-weighed by the advantages listed above).

1. You will still need to use ImageIO for Image handling. There are Utilities classes to convert JavaFX images into BufferedImage (and back). So you will still need ImageIO (and JAI if you are working with JPEG2000 images). Image support in Java remains an achilles heel and it would be really nice to see some improvements.

2. Slightly slower Performance? We implemented a test case in JavaFX and another in Swing/Graphics2D and found a small hit (which we think is due to startup rather than generally being slower). I will do some more detailed investigations and document in a future article.

Overall, JavaFX is well worth investigating for the server as well as the desktop and we found it much quicker and  easier to develop Java applications with JavaFX. What are your experiences of JavaFX on the server?

This post is part of our “Java Articles Index“ series. In these articles, we aim to explore the world of Java and Javafx. Have a look through!


IDRsolutions develop a Java PDF Viewer and SDK, an Adobe forms to HTML5 forms converter, a PDF to HTML5 converter and a Java ImageIO replacement. On the blog our team post anything interesting they learn about.

Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

Updates on Java PDF Viewer roadmap from IDRsolutions

My previous blog post (5 changes we are considering in 2016 for IDRsolutions), generated lots of feedback for us (for which we would like...
Mark Stephens
58 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *

IDRsolutions Ltd 2019. All rights reserved.