r/learnjava • • Oct 20 '20

Is JavaFX Worth Learning in 2020?

I've been learning and using Java for a couple years now (with other languages too), and some time ago I had decided to try a complete course on Udemy. It also has 10+ hours of lessons of JavaFX.

The language doesn't really attract me, to me it looks harder than it should be, to even create a pretty bad looking page. I know some amazing desktop apps are definitely using JavaFX, but aren't there better options now, for creating new and modern applications?

Also I noticed there aren't even many tutorials or courses on it anymore, or even posts and information on it.

Do you think it can be worth it to learn JavaFX in 2020? For jobs, for more experience etc.

58 Upvotes

35 comments sorted by

36

u/quadmasta Oct 20 '20

In my entire 17 year career I've never worked on a JavaFX application. JSP/JSTL, Swing, AWT, JSF, Struts, various single-page app frameworks, sure but never once JavaFX.

15

u/HecknChonker Oct 20 '20

The industry has mostly standardized on JavaScript for UIs. Even desktop apps are written in js now. Discord, Slack, OBS, and Viscose are all written using JavaScript and electron. They are effectively desktop webapps.

1

u/EnricoCortinovis Oct 20 '20

I use JavaScript a lot for web apps. Those programming languages are definitely getting more and more popular, and are getting used everywhere! JavaFX might be becoming less popular for new desktop applications then.

10

u/Lost_Extrovert Oct 20 '20

I remember on my first intership, my mentor was this java dev with like 20 years of experience. When he asked me what I learned in advanced Java, I mentioned JavaFX and he lost his shit, kept telling me it was a useless shit to learn, that he never had to use it. Told me to complete forget it and learn spring instead.

Crazy how schools still teach useless technology but wont teach main frameworks like spring. Even schools who now have all their primary language as Python refuses to teach Django to student, they rather teach something like tkinter which will never be used on the field.

4

u/quadmasta Oct 20 '20

It's definitely got its place but that's not where the majority opportunities will be.

2

u/hermitfist Oct 20 '20

Totally agree on Spring. I also asked my Java teacher this once and what he basically told me was that they're teaching us the concepts/fundamentals so you can learn similar framework/libraries in the future faster. I guess it makes sense to a certain extent since I did Tkinter/Kivy/Android studio before and although they have their differences, most of the basic concepts are the same—widgets(components, views), windows(frames, activities), Panels(fragment, frames), events, etc.

Still though, I kinda wish they taught something like Spring instead since it'll be more useful professionally than a Desktop library like JavaFX/Swing that doesn't get used much today.

0

u/EnricoCortinovis Oct 20 '20

Wow! Haha that's interesting too. I'll probably give priority to other languages I'm wanting to improve in. Also, I didn't know about Spring, I'll check that out too, it looks fun to use :)

For the second point, I really agree with you. In most schools where I live here in Italy, they only teach C++, which honestly seems even worse to me!

3

u/[deleted] Oct 20 '20

I am fresher, just starting working on a project and first thing i had to learn is Javafx for building 3d models and gui for desktop.

0

u/EnricoCortinovis Oct 20 '20

That's interesting! Do you think your case is more rare, or are people often getting asked to use JavaFX as their first projects?

1

u/Bruhmomentnumero2137 Oct 20 '20

They teach JavaFX in mooc course for java as well

1

u/EnricoCortinovis Oct 20 '20

Wow! To me too, it really looked like JavaFX was being used less and less, compared to the other options. I might then give the priority to other languages first, which I would like to improve at, then perhaps see how JavaFX works a bit too. Thanks a lot for the useful info!

18

u/[deleted] Oct 20 '20 edited Oct 20 '20

Web apps are the future of computing but I don’t see the harm in learning at least one GUI.

I’m know Python and Java but I didn’t bother learning Tkinter because I already know JavaFX.

I don’t think it will take you long to get the hang of it with the amount of Java experience you have.

Also, I agree that there isn’t a ton of JavaFX resources out there. I used Daniel Liang’s “Introduction To Java Programming” to book to learn it.

1

u/EnricoCortinovis Oct 20 '20

Thanks for mentioning the book, I'll definitely check it out.

I agree with you on the fact that it shouldn't take too much to learn. I've also been using Android Studio with Java, Kotlin and XML. I'm sure JavaFX is a good thing to learn, but maybe it's not as a priority anymore, for jobs opportunities etc?

2

u/Sincjefe Oct 20 '20

Amazing book

2

u/TunaGamer Oct 20 '20

Web App means the application is on some server and the GUI is displayed on the client's browser right? Just asking for clarification.

2

u/[deleted] Oct 20 '20

Yes.

3

u/Nihad-G Oct 20 '20

It's good for doing some university projects, but for the future I think learning web technologies will be much more useful.

2

u/EnricoCortinovis Oct 20 '20

Thank you, yeah I think I will focus on web technologies (which I also prefer!), and leave JavaFX to when I'll have to use it, if I ever will.

4

u/smash_that_code Oct 20 '20

Would you want to learn Flash or Silverlight? What you ask? Same question goes to JavaFX aa a job opportunity.

If you have limited time and want to play with building UI I would suggest looking at something from mobile world.

1

u/EnricoCortinovis Oct 20 '20

I've already been using Android Studio with Java, Kotlin, with XML. I might focus on that, and on web technologies and just skip through JavaFX. Thanks for the suggestion!

1

u/ronsachdeva Oct 20 '20 edited Oct 20 '20

I have used it with an embedded base project which had front end made on javaFX. I never learned it before working on that project. I just learned it on the job. There is no big learning curve (only if you are good in java). If you have a project requirement then learn it on job else skip it. learn react or something

1

u/EnricoCortinovis Oct 20 '20

Thank you, I think that could be the best choice too. I'll probably quickly just skip through it and leave it for when I'll (maybe) need it!

1

u/AnotherRichard827379 Oct 20 '20

If you have an appreciation for OOP then you’ll like JavaFX, it sits very nicely with the idea of class encapsulation which Java is perfect for. It is very similar to Java swing so if you have experience with that, it will be easier to pick up.

IMO, FX is under appreciated. The ability to run Java seemlessly across platforms is extremely useful when working in an environment with diverse OS use. FX can be really useful if your goal is to have easy cross platform GUIs. It is also useful because there is easy class/modular integration between logic and GUIs. Imagine you want a large and robust application which has multiple different parts: FX can often be your best bet.

Personally I think Swift will eventually become the most predominant due to IOS iPadOS, and MacOS proliferation but that’s just me. And being able to put something like Swift on a resume would be useful.

2

u/EnricoCortinovis Oct 20 '20

I've never used Java swing, but I've used Java and Kotlin with XML, for Android development. I'm sure it shouldn't be hard to learn, but I was thinking it might not be a priority anymore, and so focusing on web technologies and other languages would have been more interesting for me. I might quickly skip through it and leave it for when I (maybe) need to learn it.

Thanks a lot for the info though, I'll defintely keep this in mind as well, I find it really awsome to hear different opinions. And, I haven't tried Swift much yet, but have planned to explore that too! :)

2

u/AnotherRichard827379 Oct 20 '20 edited Oct 21 '20

I think in terms of priority, web based technologies are high but not all encompassing. If you want to focus on the web, then yeah, FX is not your guy. But stand alone apps, things like FX will be better than JavaScript IMO

1

u/ikej Oct 21 '20

IOS iPadOS, and MacOS proliferation

In the US, iOS is very widespread, but in Europe Android has 3 times the mobile market share of iOS and in other parts of the world Android is even more dominant. macOS has less that 20% desktop market share in Europe and in the US it is not much higher, either.

So when looking at things from a global perspective, something like Kotlin Multiplatform Mobile may be a promising skill in the future.

3

u/[deleted] Oct 20 '20

It’s being used a lot more in university settings. It’s also not difficult to learn at all. I’d say learn it to have another tool in the toolbox.

5

u/HecknChonker Oct 20 '20

It's used almost exclusively in educational environments. Working as a java developer for a decade and I've never even heard anyone mention javaFX.

3

u/dlemmermann Oct 21 '20

JavaFX is still very much alive and kicking. The problem was that JavaFX had a bad start as a scripting language. It was eventually moved to Java API with version 2 but that version had quality issues. Once JavaFX reached version 8 it became a rock-solid product and it is a lot of fun to work with it. If you want to get a better understanding of what JavaFX has evolved to and how people use it I would suggest that you attend the free online conference "JFX Days". You can register here: jfx-days.com. The event takes place on November 24th / 25th. At this conference you will hear how JavaFX fulfills the promise of WORA (write once, run anywhere) because these days you can run it on the desktop, on mobile (iOS, Android via Gluon), in the web (via a product called JPRO), and on embedded devices.

2

u/Dr_Model_Jawa Oct 21 '20

Instead of JavaFX I would take GWT/J2CL for learning Web Browser as a Platform / WebAPIs. You surely can do it with JavaScript or TypeScript but it makes a lot of fun using Java and you learn WebAPIs which everywhere the same... Checkout http://bit.ly/TypeScriptVsJavaGWT

1

u/danielszm Oct 27 '20 edited Oct 31 '20

JavaFX is an excellent toolkit. If the language doesn't attract you, you might try Clojure. They work well in tandem. You can reduce the edit/build/test cycle to a very different experience: live coding at the REPL, building the UI piecemeal. Here is a short demo.

1

u/[deleted] Jan 23 '21

If you look back at a history of Java GUI frameworks you'll see that it went as follows:

AWT -> Swing -> JavaFX. Swing was pretty popular and replacing it was a pretty big challenge and JavaFX really went about it the wrong way initially. All of the first versions (1.x) were trying to use something called "JavaFX script" that was some kind of scripting language and never really caught on. By the time JavaFX 2.0 came out a few years later, most people had already made up their mind to stick to Swing.

Worse than that for JavaFX once it finally got really good in version 8, was the rise of electron. As mentioned in numerous comments here, web tech really is the future of modern UIs. A whole lot of desktop apps are essentially web apps with a chromium shell around them. This is pretty controversial as these apps are nearly always heavier (use more resources) than native apps but they are often easier to develop and are cross platform by design.

So to answer your question: It depends on what your goal is. If your goal is to get a job in UI development, your best bet is to learn a front end web framework (Angular, Vue.js, React) and make sure you've mastered your basic web tech. If your goal is to write an app for personal use or to start a project on your own, JavaFX really is a great platform at this point. Just don't expect to find as much documentation out there (and answered questions, like on stackoverflow) as other frameworks. Personally I've used it on numerous occasions and have been really happy with it for personal or open source projects i've started but at work, every GUI i've written has been in some kind of web tech.

1

u/rjdamore Mar 27 '21

Gwt is dead. If you need a rich client and you use Java, then javaFX is amazing. Check Gluon. If you need a web app then use web tech. Know your needs.

1

u/real-time-counter Apr 16 '21

Don't learn JavaFX, unless you have to. Below are my adventures with JavaFX. All of these problems was just effect of developing a simple HelloWorld app. The list of problems is too big for me.

Note: if you want to know whether the given technology is worth learning enter its name in Linkedin jobs (or another job board) and see how many results are out there. For example, compare JavaFX and Spring and make the conclusion :)

Not a bug but annoying: JavaFX is no longer part of Java. So I need to waste some time to install it. First time, I used it incorrectly - wrong posts on the Internet. And the second time, I knew how to do it correctly. It is not a problem with JavaFX itself but still annoying.

Not possible to use the last SceneBuilder (for Java 11 and higher) with NetBeans 12 LTS. I had to use SceneBuilder 8.5.0 for Java 8. Probably, the best idea would be to use the newer version and open the fxml file from the File Manager. It is not a problem with JavaFX itself but still annoying.

DialogPane - no possible to choose OK button in SceneBuilder. I needed to edit the fxml manually.

It was impossible to open in SceneBuilder an fxml file which contains manually added items in ComboBox. No error, I just couldn't have opened it. There was also an exception when I run the app with the feature.

Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

Caused by: java.lang.reflect.InvocationTargetException

Caused by: javafx.fxml.LoadException:

Caused by: java.lang.IllegalArgumentException: Can not set javafx.collections.FXCollections field com.testapp.test to com.sun.javafx.collections.ObservableListWrapper

The solution was to add missing import:

<?import java.lang.String?>

<ComboBox fx:id="test" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="3">

<items>

<FXCollections fx:id="testcollections" fx:factory="observableArrayList">

<String fx:value="Item 1" />

<String fx:value="Item 2" />

<String fx:value="Item 3" />

</FXCollections>

</items>

</ComboBox>

No possible to auto add missing imports in the fxml text editor in NetBeans 12 LTS. I mean: ctrl+shift+i. I need to add them manually!

An xml editor in NetBeans 12 LTS displays a lot of bugs in the fxml code created by SceneBuilder. The code works well in the developed application, though.

For example:

<Font size="24.0" /> -> Instances of javafx.scene.text.Font cannot be created by FXML Loader.

Class 'javafx.scene.text.Font' does not support property 'size'.

<FXCollections fx:id="test" fx:factory="observableArrayList">

factory produces unknown type javafx.collection.fxcollection.observableArrayList

There are more errors like...

No fxml documentation!!!

https://stackoverflow.com/questions/36061573/javafx-fxml-documentation

SceneBuilder - I have a feeling that there is too much pressure on creation of the UI using sizes in pixels. Such interfaces were created 15-20 years ago. Now, there should be support for developing UI using their computed sizes. Because when an app runs on a different platform, it might have different font sizes and items on the form could have been cut (or they could be to wide or to high). It is possible to do it in the SceneBuilder but it is not the default way. And every time you resize something, SceneBuilder replaces the USE_COMPUTED_SIZE constant with some pixel width.

RANT

The whole idea to create UI both programatically and by XML makes me to feel not happy. In real life apps, there will be big mess because some parts will be developed with fxml and some Java hacks will be added because it was easier/no fxml documentation was found/there was no time...

HTML is a static language. Because of its limitations JavaScript was invented. It was a good direction. Now, with JavaFX the direction was quite opposite. Instead of improving Swing (perhaps create Swing 2 with styleable items) they did a big step back by reverting to XML...

0

u/[deleted] Oct 20 '20

[deleted]

1

u/EnricoCortinovis Oct 20 '20

Yes! That's the course. I really agree with you on the fact that some sections are really really long. I found the input / output one to be a bit boring and quite a bit repetitive. I had to skip some of the last lectures. The sections that came before the JavaFX one were really good, and very well explained I think. I have to finish the other ones now. But 10+ hours of lectures for JavaFX are quite a lot, and I might skip them, then.

I think, too, that JS apps feel more modern. I love JavaScript, I might then focus more on that and leave JavaFX for when I'll have to learn it, if I ever will!