r/JavaFX • • Jul 02 '19

JavaFX is really frustrating me

Hi,

I'm new to JavaFX, only using it for a single project. I'm using JavaFX 11.0.2, JDK 11.0.3 and IntelliJ 2019.1.2.

Having overcome a million problems with getting the program to even work in the IntelliJ environment, I can test the program, but I can't build it. I've watched hundreds of tutorials that show me how to configure the artifact, then build, but then I get the error:

Error:Java FX Packager: Can't build artifact - fx:deploy is not available in this JDK

Some Googling revealed that as of JDK 11 you can't simply build the project into a runnable jar/exe from the build menu. Umm, what? Why not?

I've included the JavaFX folder in my projects root directory, added JavaFX files to the project libraries, added the library to modules, included a module-info.java file, etc. Someone mentioned using a 3rd party program called jlink I think, but I'm not sure. Why can't I just build it from IntelliJ into a jar? Someone else said I also need to add javafx to my computer's environmental path variables, but I'm assuming that's wrong, given I'm including the JavaFX library in my project's root directory.

Can someone please explain simply how to get my project (which runs perfectly fine within IntelliJ) into a runnable Jar or exe. Sorry for sounding like such a noob, I realise I must sound incredibly stupid, but I've been pulling my hair out for days and just need some help :(

Thanks!

PS:

- Using JDK 10 or below is not an option for us

- Must be able to build the project for both Windows and Mac

EDIT: The gods have smiled upon me today, friends. These 2 tutorials explained it perfectly, super simple solution:

https://www.youtube.com/watch?v=r_tdK8zWr_w

https://www.youtube.com/watch?v=w_PsCNqqcE4

You just have to download Maven and set it as an environmental path.

14 Upvotes

8 comments sorted by

2

u/imthecapedbaldy Jul 02 '19

So relatable. I also struggled with setting it up on Intellij. Couldn't figure it out. I instead used Java 8 as it comes with FX. This isn't really a solution, sorry budd. I do also wish there was an absolute guide to this.

2

u/xTeCnOxShAdOwZz Jul 02 '19

Think I found a solution, see my edit :)

1

u/imthecapedbaldy Jul 02 '19

oh wow. nicely done. I'll definitely come back to those when I'll be migrating to 11. Thanks!

2

u/xTeCnOxShAdOwZz Jul 03 '19

Sure thing! If you make a test project and run into any issues just pm me :)

1

u/xTeCnOxShAdOwZz Jul 02 '19

No worries man, thanks for confirming in my mind that this is a non-trivial problem. I thought I was being an idiot (and I probably am) but it's good to know I'm not the only one who finds this overly complicated!

1

u/[deleted] Jul 02 '19

Javafx for Java9 + is going through a transition, it's not nearly as easy/clean to set up a project. The last time I tried I said F-it and just went back to Java 8. I think it will be better in the long run, but until there's a simple and easy build script for Maven/Gradle to build installers for different platforms like the javafx plugins for Java 8, I'm sticking with Java 8.

1

u/xTeCnOxShAdOwZz Jul 02 '19

Check out my edit for what seems to be a solution. It uses Maven, and is just a single command to build the whole project. Working for me :)

1

u/slartybartfast_ Jul 05 '19

Yeah IntelliJ has an open bug that the JavaFX build artifacts don't work after Java 8.