In my last article I explained the difference between HTML5 and SVG. Since then, another request has been for a simple answer to the question ‘What is the Difference between Java and JavaFX?’.
Here goes my attempt in 5 steps…
1. First we had Java, the Computer language
In the 1990s, Sun Microsystems created a new Computer Language called Java. It proved very popular because it made it easy to write code which focused on the problem, not on the computer platform. Lots of issues which other languages had (memory allocation and leaks, speed, porting to other devices, confusing syntax) simply did not exist in Java. So Java became a very popular language, especially on servers.
2. Adding in Applications with Graphical User Interfaces
Many users wanted to created Java programs with a graphical user interfaces. So Java gained a set of libraries (Swing) as part of Java. This allowed you to create applications in Java with user interfaces, but many developers felt Swing was over-complex and Java on the desktop never really took off as it did on the server.
3. Initial attempts to Improve with JavaFX 1.0
Sun Microsystems tried several ways to make it easier to create Java applications. One of these was a scripting language (so not Java but could be used with Java) called JavaFX 1.0 which tried to compete with Adobe Flash and Microsoft Silverlight. This allowed users to build much more complex user Interfaces (which could also include advanced timelines for events) than was possible in Swing.
It did not really take off (but managed to be the theme of several JavaOne conferences in the late 2000s). JavaFX was not Java (so it never really caught on with Java developers who did not want to learn yet another language) and it offered no real compelling advantage to non-Java developers.
4. Oracle reorganises with JavaFX 2 and above
When Oracle acquired Sun Microsystems, there was a major review of all activities. They killed off JavaFX as a scripting language but added the functionality into Java (with Java commands) and enhanced it as the new way to develop user interfaces.
While there is no longer a Scripting language, JavaFX can still be written as either Java commands or as XML commands (FXML) which Java can load. This means that you can separate the User interface from the code, and there is a nifty JavaFX designer called SceneBuilder to create layouts in FXML.
Java continues to contain the Swing library (lots of programs still use it), and Swing and JavaFX can be used together. But for writing new Java applications, JavaFX offers a much simpler way to create desktop applications. In JavaFX you can write more powerful applications with much less code. 🙂
So you can think of JavaFX as a modern part of Java which makes it easy to write desktop applications. It also works really nicely on the Raspberry Pi and other embedded devices where you want to create an application for the user to interact with.
5. Getting started with JavaFX
There are lots of JavaFX examples built in to NetBeans IDE which is a really good place to start. Create a project and tinker…
Are you a Java Developer working with PDF files?
|Free: The Java Developer's Guide to PDF|
|Convert PDF to HTML in Java|
|Convert PDF Forms to HTML5 in Java|
|Convert PDF Documents to an image in Java|
|Work with PDF Documents in Java|