IntelliJ can't recognize JavaFX 11 with OpenJDK 11 The 2019 Stack Overflow Developer Survey Results Are In Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceError: JavaFX runtime components are missing, and are required to run this application with JDK 11IntelliJ IDEA - Error: JavaFX runtime components are missing, and are required to run this applicationtrying to run javafx program on intellij jre11JavaFX code not compiling correctly in intellij-IDEA. it is throwing multiple errors at me when I try to build the applicationStart Jar in Linux “javafx/application/Application”How to open JavaFX .jar file with JDK 11?How to get JavaFX and Java 11 working in IntelliJ IDEAGradle OpenJFx11 : Error - JavaFx runtime components are missingIntelliJ IDEA 2018.2, openjdk 11 and openjfx 11 (no maven, not modular project) : Module javafx.controls not foundJavaFX packaging: NoClassDefFoundErrorHow can I permanently enable line numbers in IntelliJ?IntelliJ inspection gives “Cannot resolve symbol” but still compiles codeIDEA: javac: source release 1.7 requires target release 1.7How to change Java version for Maven in IntelliJ?stop IntelliJ IDEA to switch java language level every time the pom is reloaded (or change the default project language level)cannot resolve symbol javafx.application in IntelliJ Idea IDEMaven and JavaFX project in IntelliJ IDEAIntellij IDEA 2018.2 does not recognize the JavaFX packages with JDK 10Run a JavaFX 11 Maven project in IntelliJ IDEA using a run/debug configurationIntelliJ IDEA 2018.2, openjdk 11 and openjfx 11 (no maven, not modular project) : Module javafx.controls not found

Why doesn't shell automatically fix "useless use of cat"?

Do I have Disadvantage attacking with an off-hand weapon?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

Mortgage adviser recommends a longer term than necessary combined with overpayments

Do warforged have souls?

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Nested ellipses in tikzpicture: Chomsky hierarchy

Button changing its text & action. Good or terrible?

Is an up-to-date browser secure on an out-of-date OS?

Single author papers against my advisor's will?

Huge performance difference of the command find with and without using %M option to show permissions

Are spiders unable to hurt humans, especially very small spiders?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

Why can I use a list index as an indexing variable in a for loop?

Why are PDP-7-style microprogrammed instructions out of vogue?

Store Dynamic-accessible hidden metadata in a cell

ELI5: Why do they say that Israel would have been the fourth country to land a spacecraft on the Moon and why do they call it low cost?

What does Linus Torvalds mean when he says that Git "never ever" tracks a file?

For what reasons would an animal species NOT cross a *horizontal* land bridge?

How do spell lists change if the party levels up without taking a long rest?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

One-dimensional Japanese puzzle

Solving overdetermined system by QR decomposition

Sub-subscripts in strings cause different spacings than subscripts



IntelliJ can't recognize JavaFX 11 with OpenJDK 11



The 2019 Stack Overflow Developer Survey Results Are In
Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceError: JavaFX runtime components are missing, and are required to run this application with JDK 11IntelliJ IDEA - Error: JavaFX runtime components are missing, and are required to run this applicationtrying to run javafx program on intellij jre11JavaFX code not compiling correctly in intellij-IDEA. it is throwing multiple errors at me when I try to build the applicationStart Jar in Linux “javafx/application/Application”How to open JavaFX .jar file with JDK 11?How to get JavaFX and Java 11 working in IntelliJ IDEAGradle OpenJFx11 : Error - JavaFx runtime components are missingIntelliJ IDEA 2018.2, openjdk 11 and openjfx 11 (no maven, not modular project) : Module javafx.controls not foundJavaFX packaging: NoClassDefFoundErrorHow can I permanently enable line numbers in IntelliJ?IntelliJ inspection gives “Cannot resolve symbol” but still compiles codeIDEA: javac: source release 1.7 requires target release 1.7How to change Java version for Maven in IntelliJ?stop IntelliJ IDEA to switch java language level every time the pom is reloaded (or change the default project language level)cannot resolve symbol javafx.application in IntelliJ Idea IDEMaven and JavaFX project in IntelliJ IDEAIntellij IDEA 2018.2 does not recognize the JavaFX packages with JDK 10Run a JavaFX 11 Maven project in IntelliJ IDEA using a run/debug configurationIntelliJ IDEA 2018.2, openjdk 11 and openjfx 11 (no maven, not modular project) : Module javafx.controls not found



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








26















I'm having trouble getting IntellJ to recognize JavaFX packages. With a new JavaFX project, with OpenJDK 11, when trying to build the project, IntelliJ can't recognize the JavaFX packages.



I've imported openjfx:javafx-base-11 from the Maven repo.



I've looked at other questions and the solutions seem to range from checking that the bytecode is at the right level (mine is), and that the project language is correct (mine is).



Anyone have any ideas?



pic 1



pic 2



pic 3



Edit:



Error:



enter image description here










share|improve this question
























  • can you try from terminal to compile and run?

    – drowny
    Sep 23 '18 at 15:35











  • You'll need to require its module(s) in your module-info.java

    – Jacob G.
    Sep 23 '18 at 15:36











  • I think you need this artifact: mvnrepository.com/artifact/org.openjfx/javafx/11 the base one doesn't contain everything I guess.

    – Jorn Vernee
    Sep 23 '18 at 15:36











  • @JornVernee when I try that I get an error. I edited the OP with it.

    – AlwaysNeedingHelp
    Sep 23 '18 at 15:41











  • @JacobG. how do I go about this? I have not used the module system before. I was told that you don't require a modulized application to use javaFX11. Is this wrong?

    – AlwaysNeedingHelp
    Sep 23 '18 at 15:41

















26















I'm having trouble getting IntellJ to recognize JavaFX packages. With a new JavaFX project, with OpenJDK 11, when trying to build the project, IntelliJ can't recognize the JavaFX packages.



I've imported openjfx:javafx-base-11 from the Maven repo.



I've looked at other questions and the solutions seem to range from checking that the bytecode is at the right level (mine is), and that the project language is correct (mine is).



Anyone have any ideas?



pic 1



pic 2



pic 3



Edit:



Error:



enter image description here










share|improve this question
























  • can you try from terminal to compile and run?

    – drowny
    Sep 23 '18 at 15:35











  • You'll need to require its module(s) in your module-info.java

    – Jacob G.
    Sep 23 '18 at 15:36











  • I think you need this artifact: mvnrepository.com/artifact/org.openjfx/javafx/11 the base one doesn't contain everything I guess.

    – Jorn Vernee
    Sep 23 '18 at 15:36











  • @JornVernee when I try that I get an error. I edited the OP with it.

    – AlwaysNeedingHelp
    Sep 23 '18 at 15:41











  • @JacobG. how do I go about this? I have not used the module system before. I was told that you don't require a modulized application to use javaFX11. Is this wrong?

    – AlwaysNeedingHelp
    Sep 23 '18 at 15:41













26












26








26


19






I'm having trouble getting IntellJ to recognize JavaFX packages. With a new JavaFX project, with OpenJDK 11, when trying to build the project, IntelliJ can't recognize the JavaFX packages.



I've imported openjfx:javafx-base-11 from the Maven repo.



I've looked at other questions and the solutions seem to range from checking that the bytecode is at the right level (mine is), and that the project language is correct (mine is).



Anyone have any ideas?



pic 1



pic 2



pic 3



Edit:



Error:



enter image description here










share|improve this question
















I'm having trouble getting IntellJ to recognize JavaFX packages. With a new JavaFX project, with OpenJDK 11, when trying to build the project, IntelliJ can't recognize the JavaFX packages.



I've imported openjfx:javafx-base-11 from the Maven repo.



I've looked at other questions and the solutions seem to range from checking that the bytecode is at the right level (mine is), and that the project language is correct (mine is).



Anyone have any ideas?



pic 1



pic 2



pic 3



Edit:



Error:



enter image description here







java intellij-idea javafx java-11 javafx-11






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 5 at 2:12









LAD

2,09741026




2,09741026










asked Sep 23 '18 at 15:25









AlwaysNeedingHelpAlwaysNeedingHelp

3641618




3641618












  • can you try from terminal to compile and run?

    – drowny
    Sep 23 '18 at 15:35











  • You'll need to require its module(s) in your module-info.java

    – Jacob G.
    Sep 23 '18 at 15:36











  • I think you need this artifact: mvnrepository.com/artifact/org.openjfx/javafx/11 the base one doesn't contain everything I guess.

    – Jorn Vernee
    Sep 23 '18 at 15:36











  • @JornVernee when I try that I get an error. I edited the OP with it.

    – AlwaysNeedingHelp
    Sep 23 '18 at 15:41











  • @JacobG. how do I go about this? I have not used the module system before. I was told that you don't require a modulized application to use javaFX11. Is this wrong?

    – AlwaysNeedingHelp
    Sep 23 '18 at 15:41

















  • can you try from terminal to compile and run?

    – drowny
    Sep 23 '18 at 15:35











  • You'll need to require its module(s) in your module-info.java

    – Jacob G.
    Sep 23 '18 at 15:36











  • I think you need this artifact: mvnrepository.com/artifact/org.openjfx/javafx/11 the base one doesn't contain everything I guess.

    – Jorn Vernee
    Sep 23 '18 at 15:36











  • @JornVernee when I try that I get an error. I edited the OP with it.

    – AlwaysNeedingHelp
    Sep 23 '18 at 15:41











  • @JacobG. how do I go about this? I have not used the module system before. I was told that you don't require a modulized application to use javaFX11. Is this wrong?

    – AlwaysNeedingHelp
    Sep 23 '18 at 15:41
















can you try from terminal to compile and run?

– drowny
Sep 23 '18 at 15:35





can you try from terminal to compile and run?

– drowny
Sep 23 '18 at 15:35













You'll need to require its module(s) in your module-info.java

– Jacob G.
Sep 23 '18 at 15:36





You'll need to require its module(s) in your module-info.java

– Jacob G.
Sep 23 '18 at 15:36













I think you need this artifact: mvnrepository.com/artifact/org.openjfx/javafx/11 the base one doesn't contain everything I guess.

– Jorn Vernee
Sep 23 '18 at 15:36





I think you need this artifact: mvnrepository.com/artifact/org.openjfx/javafx/11 the base one doesn't contain everything I guess.

– Jorn Vernee
Sep 23 '18 at 15:36













@JornVernee when I try that I get an error. I edited the OP with it.

– AlwaysNeedingHelp
Sep 23 '18 at 15:41





@JornVernee when I try that I get an error. I edited the OP with it.

– AlwaysNeedingHelp
Sep 23 '18 at 15:41













@JacobG. how do I go about this? I have not used the module system before. I was told that you don't require a modulized application to use javaFX11. Is this wrong?

– AlwaysNeedingHelp
Sep 23 '18 at 15:41





@JacobG. how do I go about this? I have not used the module system before. I was told that you don't require a modulized application to use javaFX11. Is this wrong?

– AlwaysNeedingHelp
Sep 23 '18 at 15:41












1 Answer
1






active

oldest

votes


















59














As mentioned in the comments, the Starting Guide is the place to start with Java 11 and JavaFX 11.



The key to work as you did before Java 11 is to understand that:



  • JavaFX 11 is not part of the JDK anymore

  • You can get it in different flavors, either as an SDK or as
    regular dependencies (maven/gradle).

  • You will need to include it to the module path of your project, even if your project is not modular.

JavaFX project



If you create a regular JavaFX default project in IntelliJ (without Maven or Gradle) I'd suggest you download the SDK from here. Note that there are jmods as well, but for a non modular project the SDK is preferred.



These are the easy steps to run the default project:



  1. Create a JavaFX project

  2. Set JDK 11 (point to your local Java 11 version)

  3. Add the JavaFX 11 SDK as a library. The URL could be something like /Users/<user>/Downloads/javafx-sdk-11/lib/. Once you do this you will notice that the JavaFX classes are now recognized in the editor.

JavaFX 11 Project




  1. Before you run the default project, you just need to add these to the VM options:



    --module-path /Users/<user>/Downloads/javafx-sdk-11/lib --add-modules=javafx.controls,javafx.fxml



  2. Run


Maven



If you use Maven to build your project, follow these steps:



  1. Create a Maven project with JavaFX archetype

  2. Set JDK 11 (point to your local Java 11 version)


  3. Add the JavaFX 11 dependencies.



    <dependencies>
    <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>11</version>
    </dependency>
    <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>11</version>
    </dependency>
    </dependencies>


Once you do this you will notice that the JavaFX classes are now recognized in the editor.



JavaFX 11 Maven project



You will notice that Maven manages the required dependencies for you: it will add javafx.base and javafx.graphics for javafx.controls, but most important, it will add the required classifier based on your platform. In my case, Mac.



This is why your jars org.openjfx:javafx-controls:11 are empty, because there are three possible classifiers (windows, linux and mac platforms), that contain all the classes and the native implementation.



In case you still want to go to your .m2 repo and take the dependencies from there manually, make sure you pick the right one (for instance .m2/repository/org/openjfx/javafx-controls/11/javafx-controls-11-mac.jar)



  1. Replace default maven plugins with those from here.


  2. Run mvn compile exec:java, and it should work.


Similar works as well for Gradle projects, as explained in detail here.



EDIT



The mentioned Getting Started guide contains updated documentation and sample projects for IntelliJ:



  • JavaFX 11 without Maven/Gradle, see non-modular sample or modular sample projects.


  • JavaFX 11 with Maven, see non-modular sample or modular sample projects.


  • JavaFX 11 with Gradle, see non-modular sample or modular sample projects.






share|improve this answer

























  • I am having trouble with JavaFX Project Step 3. Project Structure -> Project Settings -> Libraries -> + (New Project Library) -> Java. Then input path to javafx-sdk-11, correct? Then, "IDEA cannot determine what kind of files the chosen items contain. Choose the appropriate categories from the list."

    – Jack J
    Oct 6 '18 at 19:24






  • 1





    Path is something like /Users/<user>/Downloads/javafx-sdk-11/lib/, notice the lib folder. That should contain all the javafx jars

    – José Pereda
    Oct 6 '18 at 19:26






  • 5





    If anyone is having issues with the module path it needs to look something like this on windows: --module-path="C:PathToYourJavaFXlib" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.graphics,javafx.swing,javafx.web Notice the "=" and also the quotes around it. This worked for me while any other approach didn't. Furthermore keep in mind that the -jar YourJar.jar parameter needs to come AFTER the module path and add-modules options.

    – Jalau
    Oct 25 '18 at 10:58






  • 1





    Hi @JoséPereda. I've been struggling with this guide since a while, but I can't really make IntelliJ run my code, even if I've done exactly what you've written. I'm still getting "Error:java: module not found: javafx.fxml" and so on. Any chance to have a private chat to help me out sort out this issue? Thank you.

    – Davide3i
    Dec 22 '18 at 17:22






  • 1





    @jalau thank you! the quotes actually did it, you should write this as an answer.

    – derfect
    Jan 18 at 15:54









protected by kleopatra Nov 5 '18 at 9:21



Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



Would you like to answer one of these unanswered questions instead?














1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









59














As mentioned in the comments, the Starting Guide is the place to start with Java 11 and JavaFX 11.



The key to work as you did before Java 11 is to understand that:



  • JavaFX 11 is not part of the JDK anymore

  • You can get it in different flavors, either as an SDK or as
    regular dependencies (maven/gradle).

  • You will need to include it to the module path of your project, even if your project is not modular.

JavaFX project



If you create a regular JavaFX default project in IntelliJ (without Maven or Gradle) I'd suggest you download the SDK from here. Note that there are jmods as well, but for a non modular project the SDK is preferred.



These are the easy steps to run the default project:



  1. Create a JavaFX project

  2. Set JDK 11 (point to your local Java 11 version)

  3. Add the JavaFX 11 SDK as a library. The URL could be something like /Users/<user>/Downloads/javafx-sdk-11/lib/. Once you do this you will notice that the JavaFX classes are now recognized in the editor.

JavaFX 11 Project




  1. Before you run the default project, you just need to add these to the VM options:



    --module-path /Users/<user>/Downloads/javafx-sdk-11/lib --add-modules=javafx.controls,javafx.fxml



  2. Run


Maven



If you use Maven to build your project, follow these steps:



  1. Create a Maven project with JavaFX archetype

  2. Set JDK 11 (point to your local Java 11 version)


  3. Add the JavaFX 11 dependencies.



    <dependencies>
    <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>11</version>
    </dependency>
    <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>11</version>
    </dependency>
    </dependencies>


Once you do this you will notice that the JavaFX classes are now recognized in the editor.



JavaFX 11 Maven project



You will notice that Maven manages the required dependencies for you: it will add javafx.base and javafx.graphics for javafx.controls, but most important, it will add the required classifier based on your platform. In my case, Mac.



This is why your jars org.openjfx:javafx-controls:11 are empty, because there are three possible classifiers (windows, linux and mac platforms), that contain all the classes and the native implementation.



In case you still want to go to your .m2 repo and take the dependencies from there manually, make sure you pick the right one (for instance .m2/repository/org/openjfx/javafx-controls/11/javafx-controls-11-mac.jar)



  1. Replace default maven plugins with those from here.


  2. Run mvn compile exec:java, and it should work.


Similar works as well for Gradle projects, as explained in detail here.



EDIT



The mentioned Getting Started guide contains updated documentation and sample projects for IntelliJ:



  • JavaFX 11 without Maven/Gradle, see non-modular sample or modular sample projects.


  • JavaFX 11 with Maven, see non-modular sample or modular sample projects.


  • JavaFX 11 with Gradle, see non-modular sample or modular sample projects.






share|improve this answer

























  • I am having trouble with JavaFX Project Step 3. Project Structure -> Project Settings -> Libraries -> + (New Project Library) -> Java. Then input path to javafx-sdk-11, correct? Then, "IDEA cannot determine what kind of files the chosen items contain. Choose the appropriate categories from the list."

    – Jack J
    Oct 6 '18 at 19:24






  • 1





    Path is something like /Users/<user>/Downloads/javafx-sdk-11/lib/, notice the lib folder. That should contain all the javafx jars

    – José Pereda
    Oct 6 '18 at 19:26






  • 5





    If anyone is having issues with the module path it needs to look something like this on windows: --module-path="C:PathToYourJavaFXlib" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.graphics,javafx.swing,javafx.web Notice the "=" and also the quotes around it. This worked for me while any other approach didn't. Furthermore keep in mind that the -jar YourJar.jar parameter needs to come AFTER the module path and add-modules options.

    – Jalau
    Oct 25 '18 at 10:58






  • 1





    Hi @JoséPereda. I've been struggling with this guide since a while, but I can't really make IntelliJ run my code, even if I've done exactly what you've written. I'm still getting "Error:java: module not found: javafx.fxml" and so on. Any chance to have a private chat to help me out sort out this issue? Thank you.

    – Davide3i
    Dec 22 '18 at 17:22






  • 1





    @jalau thank you! the quotes actually did it, you should write this as an answer.

    – derfect
    Jan 18 at 15:54















59














As mentioned in the comments, the Starting Guide is the place to start with Java 11 and JavaFX 11.



The key to work as you did before Java 11 is to understand that:



  • JavaFX 11 is not part of the JDK anymore

  • You can get it in different flavors, either as an SDK or as
    regular dependencies (maven/gradle).

  • You will need to include it to the module path of your project, even if your project is not modular.

JavaFX project



If you create a regular JavaFX default project in IntelliJ (without Maven or Gradle) I'd suggest you download the SDK from here. Note that there are jmods as well, but for a non modular project the SDK is preferred.



These are the easy steps to run the default project:



  1. Create a JavaFX project

  2. Set JDK 11 (point to your local Java 11 version)

  3. Add the JavaFX 11 SDK as a library. The URL could be something like /Users/<user>/Downloads/javafx-sdk-11/lib/. Once you do this you will notice that the JavaFX classes are now recognized in the editor.

JavaFX 11 Project




  1. Before you run the default project, you just need to add these to the VM options:



    --module-path /Users/<user>/Downloads/javafx-sdk-11/lib --add-modules=javafx.controls,javafx.fxml



  2. Run


Maven



If you use Maven to build your project, follow these steps:



  1. Create a Maven project with JavaFX archetype

  2. Set JDK 11 (point to your local Java 11 version)


  3. Add the JavaFX 11 dependencies.



    <dependencies>
    <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>11</version>
    </dependency>
    <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>11</version>
    </dependency>
    </dependencies>


Once you do this you will notice that the JavaFX classes are now recognized in the editor.



JavaFX 11 Maven project



You will notice that Maven manages the required dependencies for you: it will add javafx.base and javafx.graphics for javafx.controls, but most important, it will add the required classifier based on your platform. In my case, Mac.



This is why your jars org.openjfx:javafx-controls:11 are empty, because there are three possible classifiers (windows, linux and mac platforms), that contain all the classes and the native implementation.



In case you still want to go to your .m2 repo and take the dependencies from there manually, make sure you pick the right one (for instance .m2/repository/org/openjfx/javafx-controls/11/javafx-controls-11-mac.jar)



  1. Replace default maven plugins with those from here.


  2. Run mvn compile exec:java, and it should work.


Similar works as well for Gradle projects, as explained in detail here.



EDIT



The mentioned Getting Started guide contains updated documentation and sample projects for IntelliJ:



  • JavaFX 11 without Maven/Gradle, see non-modular sample or modular sample projects.


  • JavaFX 11 with Maven, see non-modular sample or modular sample projects.


  • JavaFX 11 with Gradle, see non-modular sample or modular sample projects.






share|improve this answer

























  • I am having trouble with JavaFX Project Step 3. Project Structure -> Project Settings -> Libraries -> + (New Project Library) -> Java. Then input path to javafx-sdk-11, correct? Then, "IDEA cannot determine what kind of files the chosen items contain. Choose the appropriate categories from the list."

    – Jack J
    Oct 6 '18 at 19:24






  • 1





    Path is something like /Users/<user>/Downloads/javafx-sdk-11/lib/, notice the lib folder. That should contain all the javafx jars

    – José Pereda
    Oct 6 '18 at 19:26






  • 5





    If anyone is having issues with the module path it needs to look something like this on windows: --module-path="C:PathToYourJavaFXlib" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.graphics,javafx.swing,javafx.web Notice the "=" and also the quotes around it. This worked for me while any other approach didn't. Furthermore keep in mind that the -jar YourJar.jar parameter needs to come AFTER the module path and add-modules options.

    – Jalau
    Oct 25 '18 at 10:58






  • 1





    Hi @JoséPereda. I've been struggling with this guide since a while, but I can't really make IntelliJ run my code, even if I've done exactly what you've written. I'm still getting "Error:java: module not found: javafx.fxml" and so on. Any chance to have a private chat to help me out sort out this issue? Thank you.

    – Davide3i
    Dec 22 '18 at 17:22






  • 1





    @jalau thank you! the quotes actually did it, you should write this as an answer.

    – derfect
    Jan 18 at 15:54













59












59








59







As mentioned in the comments, the Starting Guide is the place to start with Java 11 and JavaFX 11.



The key to work as you did before Java 11 is to understand that:



  • JavaFX 11 is not part of the JDK anymore

  • You can get it in different flavors, either as an SDK or as
    regular dependencies (maven/gradle).

  • You will need to include it to the module path of your project, even if your project is not modular.

JavaFX project



If you create a regular JavaFX default project in IntelliJ (without Maven or Gradle) I'd suggest you download the SDK from here. Note that there are jmods as well, but for a non modular project the SDK is preferred.



These are the easy steps to run the default project:



  1. Create a JavaFX project

  2. Set JDK 11 (point to your local Java 11 version)

  3. Add the JavaFX 11 SDK as a library. The URL could be something like /Users/<user>/Downloads/javafx-sdk-11/lib/. Once you do this you will notice that the JavaFX classes are now recognized in the editor.

JavaFX 11 Project




  1. Before you run the default project, you just need to add these to the VM options:



    --module-path /Users/<user>/Downloads/javafx-sdk-11/lib --add-modules=javafx.controls,javafx.fxml



  2. Run


Maven



If you use Maven to build your project, follow these steps:



  1. Create a Maven project with JavaFX archetype

  2. Set JDK 11 (point to your local Java 11 version)


  3. Add the JavaFX 11 dependencies.



    <dependencies>
    <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>11</version>
    </dependency>
    <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>11</version>
    </dependency>
    </dependencies>


Once you do this you will notice that the JavaFX classes are now recognized in the editor.



JavaFX 11 Maven project



You will notice that Maven manages the required dependencies for you: it will add javafx.base and javafx.graphics for javafx.controls, but most important, it will add the required classifier based on your platform. In my case, Mac.



This is why your jars org.openjfx:javafx-controls:11 are empty, because there are three possible classifiers (windows, linux and mac platforms), that contain all the classes and the native implementation.



In case you still want to go to your .m2 repo and take the dependencies from there manually, make sure you pick the right one (for instance .m2/repository/org/openjfx/javafx-controls/11/javafx-controls-11-mac.jar)



  1. Replace default maven plugins with those from here.


  2. Run mvn compile exec:java, and it should work.


Similar works as well for Gradle projects, as explained in detail here.



EDIT



The mentioned Getting Started guide contains updated documentation and sample projects for IntelliJ:



  • JavaFX 11 without Maven/Gradle, see non-modular sample or modular sample projects.


  • JavaFX 11 with Maven, see non-modular sample or modular sample projects.


  • JavaFX 11 with Gradle, see non-modular sample or modular sample projects.






share|improve this answer















As mentioned in the comments, the Starting Guide is the place to start with Java 11 and JavaFX 11.



The key to work as you did before Java 11 is to understand that:



  • JavaFX 11 is not part of the JDK anymore

  • You can get it in different flavors, either as an SDK or as
    regular dependencies (maven/gradle).

  • You will need to include it to the module path of your project, even if your project is not modular.

JavaFX project



If you create a regular JavaFX default project in IntelliJ (without Maven or Gradle) I'd suggest you download the SDK from here. Note that there are jmods as well, but for a non modular project the SDK is preferred.



These are the easy steps to run the default project:



  1. Create a JavaFX project

  2. Set JDK 11 (point to your local Java 11 version)

  3. Add the JavaFX 11 SDK as a library. The URL could be something like /Users/<user>/Downloads/javafx-sdk-11/lib/. Once you do this you will notice that the JavaFX classes are now recognized in the editor.

JavaFX 11 Project




  1. Before you run the default project, you just need to add these to the VM options:



    --module-path /Users/<user>/Downloads/javafx-sdk-11/lib --add-modules=javafx.controls,javafx.fxml



  2. Run


Maven



If you use Maven to build your project, follow these steps:



  1. Create a Maven project with JavaFX archetype

  2. Set JDK 11 (point to your local Java 11 version)


  3. Add the JavaFX 11 dependencies.



    <dependencies>
    <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>11</version>
    </dependency>
    <dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-fxml</artifactId>
    <version>11</version>
    </dependency>
    </dependencies>


Once you do this you will notice that the JavaFX classes are now recognized in the editor.



JavaFX 11 Maven project



You will notice that Maven manages the required dependencies for you: it will add javafx.base and javafx.graphics for javafx.controls, but most important, it will add the required classifier based on your platform. In my case, Mac.



This is why your jars org.openjfx:javafx-controls:11 are empty, because there are three possible classifiers (windows, linux and mac platforms), that contain all the classes and the native implementation.



In case you still want to go to your .m2 repo and take the dependencies from there manually, make sure you pick the right one (for instance .m2/repository/org/openjfx/javafx-controls/11/javafx-controls-11-mac.jar)



  1. Replace default maven plugins with those from here.


  2. Run mvn compile exec:java, and it should work.


Similar works as well for Gradle projects, as explained in detail here.



EDIT



The mentioned Getting Started guide contains updated documentation and sample projects for IntelliJ:



  • JavaFX 11 without Maven/Gradle, see non-modular sample or modular sample projects.


  • JavaFX 11 with Maven, see non-modular sample or modular sample projects.


  • JavaFX 11 with Gradle, see non-modular sample or modular sample projects.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 27 '18 at 17:43

























answered Sep 23 '18 at 20:49









José PeredaJosé Pereda

27.3k34675




27.3k34675












  • I am having trouble with JavaFX Project Step 3. Project Structure -> Project Settings -> Libraries -> + (New Project Library) -> Java. Then input path to javafx-sdk-11, correct? Then, "IDEA cannot determine what kind of files the chosen items contain. Choose the appropriate categories from the list."

    – Jack J
    Oct 6 '18 at 19:24






  • 1





    Path is something like /Users/<user>/Downloads/javafx-sdk-11/lib/, notice the lib folder. That should contain all the javafx jars

    – José Pereda
    Oct 6 '18 at 19:26






  • 5





    If anyone is having issues with the module path it needs to look something like this on windows: --module-path="C:PathToYourJavaFXlib" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.graphics,javafx.swing,javafx.web Notice the "=" and also the quotes around it. This worked for me while any other approach didn't. Furthermore keep in mind that the -jar YourJar.jar parameter needs to come AFTER the module path and add-modules options.

    – Jalau
    Oct 25 '18 at 10:58






  • 1





    Hi @JoséPereda. I've been struggling with this guide since a while, but I can't really make IntelliJ run my code, even if I've done exactly what you've written. I'm still getting "Error:java: module not found: javafx.fxml" and so on. Any chance to have a private chat to help me out sort out this issue? Thank you.

    – Davide3i
    Dec 22 '18 at 17:22






  • 1





    @jalau thank you! the quotes actually did it, you should write this as an answer.

    – derfect
    Jan 18 at 15:54

















  • I am having trouble with JavaFX Project Step 3. Project Structure -> Project Settings -> Libraries -> + (New Project Library) -> Java. Then input path to javafx-sdk-11, correct? Then, "IDEA cannot determine what kind of files the chosen items contain. Choose the appropriate categories from the list."

    – Jack J
    Oct 6 '18 at 19:24






  • 1





    Path is something like /Users/<user>/Downloads/javafx-sdk-11/lib/, notice the lib folder. That should contain all the javafx jars

    – José Pereda
    Oct 6 '18 at 19:26






  • 5





    If anyone is having issues with the module path it needs to look something like this on windows: --module-path="C:PathToYourJavaFXlib" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.graphics,javafx.swing,javafx.web Notice the "=" and also the quotes around it. This worked for me while any other approach didn't. Furthermore keep in mind that the -jar YourJar.jar parameter needs to come AFTER the module path and add-modules options.

    – Jalau
    Oct 25 '18 at 10:58






  • 1





    Hi @JoséPereda. I've been struggling with this guide since a while, but I can't really make IntelliJ run my code, even if I've done exactly what you've written. I'm still getting "Error:java: module not found: javafx.fxml" and so on. Any chance to have a private chat to help me out sort out this issue? Thank you.

    – Davide3i
    Dec 22 '18 at 17:22






  • 1





    @jalau thank you! the quotes actually did it, you should write this as an answer.

    – derfect
    Jan 18 at 15:54
















I am having trouble with JavaFX Project Step 3. Project Structure -> Project Settings -> Libraries -> + (New Project Library) -> Java. Then input path to javafx-sdk-11, correct? Then, "IDEA cannot determine what kind of files the chosen items contain. Choose the appropriate categories from the list."

– Jack J
Oct 6 '18 at 19:24





I am having trouble with JavaFX Project Step 3. Project Structure -> Project Settings -> Libraries -> + (New Project Library) -> Java. Then input path to javafx-sdk-11, correct? Then, "IDEA cannot determine what kind of files the chosen items contain. Choose the appropriate categories from the list."

– Jack J
Oct 6 '18 at 19:24




1




1





Path is something like /Users/<user>/Downloads/javafx-sdk-11/lib/, notice the lib folder. That should contain all the javafx jars

– José Pereda
Oct 6 '18 at 19:26





Path is something like /Users/<user>/Downloads/javafx-sdk-11/lib/, notice the lib folder. That should contain all the javafx jars

– José Pereda
Oct 6 '18 at 19:26




5




5





If anyone is having issues with the module path it needs to look something like this on windows: --module-path="C:PathToYourJavaFXlib" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.graphics,javafx.swing,javafx.web Notice the "=" and also the quotes around it. This worked for me while any other approach didn't. Furthermore keep in mind that the -jar YourJar.jar parameter needs to come AFTER the module path and add-modules options.

– Jalau
Oct 25 '18 at 10:58





If anyone is having issues with the module path it needs to look something like this on windows: --module-path="C:PathToYourJavaFXlib" --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.graphics,javafx.swing,javafx.web Notice the "=" and also the quotes around it. This worked for me while any other approach didn't. Furthermore keep in mind that the -jar YourJar.jar parameter needs to come AFTER the module path and add-modules options.

– Jalau
Oct 25 '18 at 10:58




1




1





Hi @JoséPereda. I've been struggling with this guide since a while, but I can't really make IntelliJ run my code, even if I've done exactly what you've written. I'm still getting "Error:java: module not found: javafx.fxml" and so on. Any chance to have a private chat to help me out sort out this issue? Thank you.

– Davide3i
Dec 22 '18 at 17:22





Hi @JoséPereda. I've been struggling with this guide since a while, but I can't really make IntelliJ run my code, even if I've done exactly what you've written. I'm still getting "Error:java: module not found: javafx.fxml" and so on. Any chance to have a private chat to help me out sort out this issue? Thank you.

– Davide3i
Dec 22 '18 at 17:22




1




1





@jalau thank you! the quotes actually did it, you should write this as an answer.

– derfect
Jan 18 at 15:54





@jalau thank you! the quotes actually did it, you should write this as an answer.

– derfect
Jan 18 at 15:54







protected by kleopatra Nov 5 '18 at 9:21



Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



Would you like to answer one of these unanswered questions instead?