Exporting a JavaFX project with IntelliJ and Java 14

Published by admin. 3. April 2020 No Comments

Note: Click here to see how to install the last Java version on Ubuntu

If you try to export a JavaFX project to a .jar file according to many tutorials you find online, you might be getting the error Can not build artifact - fx: deploy is not available in this JDK. If you haven’t tried it yet, good for you, this post might save you a hell lot of time. Note, I am writing this in April 2020, things might change again in the future. So if this method doesn’t work, kindly leave a comment and let me know.

To solve this, follow these steps:

  • Click on File -> Project Structure -> Artifacts
  • Then, click on ‘+’ -> JAR -> From modules with dependencies
  • Select your main class as shown in the following pictures
  • Once done, click OK and OK
  • Now start building your project and pray that your .jar file will be inside the “out/artifacts/[Project Name]_jar” folder
  • Create a .sh file according to the following pattern:
java --module-path [Path to your JavaFX lib folder] --add-modules javafx.controls,javafx.fxml -jar [Your .jar file]

Note: Make sure to include all modules required by your project. Also make sure that your default java version matches the version used by IntelliJ.

Leave a Reply

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