Maven can't find FXMLLoader












2















I have a JavaFx project in which Maven install keeps giving me the error:



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project gui: Compilation failure: Compilation failure:
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[21,19] package javafx.fxml does not exist
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[29,17] cannot find symbol
[ERROR] symbol: class FXMLLoader
[ERROR] location: class gui.AppController
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[29,45] cannot find symbol
[ERROR] symbol: class FXMLLoader
[ERROR] location: class gui.AppController


What am I doing wrong? How do I persuade Maven/Eclipse/Java/Whatever find the FXMLLoader?



The project structure has two modules, gui and logic, with the project structure in this tutorial. My overall project pom is:



<modules>
<module>logic</module>
<module>gui</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>11</source>
<target>11</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>




The pom for the gui module is:



<parent>
<groupId>com.gmail.digitig</groupId>
<artifactId>gsn-notator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gui</artifactId>
<dependencies>
<dependency>
<groupId>com.gmail.digitig</groupId>
<artifactId>logic</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11-ea+19</version>
</dependency>
</dependencies>


I don't have anything in the logic module yet, other than a trivial module_info.java. Class gui.AppController, where the error is being reported, is:



package gui;

import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.BorderPane;

public class AppController extends BorderPane {
public AppController() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("App.fxml"));
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}


}










share|improve this question




















  • 1





    Few suggestions: 1. You can upgrade to the maven-compiler-plugin:3.8.0 2. You can upgrade to javafx-controls:11.0.1 3. Official sample for running JavaFX with Maven

    – nullpointer
    Nov 18 '18 at 1:55











  • Neither of the upgrades makes any difference. I have tried to align my project with the official sample, though I'm not entirely sure how to distribute it between the top level and the module. Still no change to the error - it can't find FXMLLoader. And the official sample doesn't include FXML. I had no trouble getting JavaFx apps to work with Maven until I tried to include FXML.

    – digitig
    Nov 18 '18 at 21:23
















2















I have a JavaFx project in which Maven install keeps giving me the error:



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project gui: Compilation failure: Compilation failure:
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[21,19] package javafx.fxml does not exist
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[29,17] cannot find symbol
[ERROR] symbol: class FXMLLoader
[ERROR] location: class gui.AppController
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[29,45] cannot find symbol
[ERROR] symbol: class FXMLLoader
[ERROR] location: class gui.AppController


What am I doing wrong? How do I persuade Maven/Eclipse/Java/Whatever find the FXMLLoader?



The project structure has two modules, gui and logic, with the project structure in this tutorial. My overall project pom is:



<modules>
<module>logic</module>
<module>gui</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>11</source>
<target>11</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>




The pom for the gui module is:



<parent>
<groupId>com.gmail.digitig</groupId>
<artifactId>gsn-notator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gui</artifactId>
<dependencies>
<dependency>
<groupId>com.gmail.digitig</groupId>
<artifactId>logic</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11-ea+19</version>
</dependency>
</dependencies>


I don't have anything in the logic module yet, other than a trivial module_info.java. Class gui.AppController, where the error is being reported, is:



package gui;

import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.BorderPane;

public class AppController extends BorderPane {
public AppController() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("App.fxml"));
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}


}










share|improve this question




















  • 1





    Few suggestions: 1. You can upgrade to the maven-compiler-plugin:3.8.0 2. You can upgrade to javafx-controls:11.0.1 3. Official sample for running JavaFX with Maven

    – nullpointer
    Nov 18 '18 at 1:55











  • Neither of the upgrades makes any difference. I have tried to align my project with the official sample, though I'm not entirely sure how to distribute it between the top level and the module. Still no change to the error - it can't find FXMLLoader. And the official sample doesn't include FXML. I had no trouble getting JavaFx apps to work with Maven until I tried to include FXML.

    – digitig
    Nov 18 '18 at 21:23














2












2








2


1






I have a JavaFx project in which Maven install keeps giving me the error:



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project gui: Compilation failure: Compilation failure:
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[21,19] package javafx.fxml does not exist
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[29,17] cannot find symbol
[ERROR] symbol: class FXMLLoader
[ERROR] location: class gui.AppController
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[29,45] cannot find symbol
[ERROR] symbol: class FXMLLoader
[ERROR] location: class gui.AppController


What am I doing wrong? How do I persuade Maven/Eclipse/Java/Whatever find the FXMLLoader?



The project structure has two modules, gui and logic, with the project structure in this tutorial. My overall project pom is:



<modules>
<module>logic</module>
<module>gui</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>11</source>
<target>11</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>




The pom for the gui module is:



<parent>
<groupId>com.gmail.digitig</groupId>
<artifactId>gsn-notator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gui</artifactId>
<dependencies>
<dependency>
<groupId>com.gmail.digitig</groupId>
<artifactId>logic</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11-ea+19</version>
</dependency>
</dependencies>


I don't have anything in the logic module yet, other than a trivial module_info.java. Class gui.AppController, where the error is being reported, is:



package gui;

import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.BorderPane;

public class AppController extends BorderPane {
public AppController() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("App.fxml"));
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}


}










share|improve this question
















I have a JavaFx project in which Maven install keeps giving me the error:



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project gui: Compilation failure: Compilation failure:
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[21,19] package javafx.fxml does not exist
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[29,17] cannot find symbol
[ERROR] symbol: class FXMLLoader
[ERROR] location: class gui.AppController
[ERROR] /C:/Users/digit/eclipse-workspace/gsn-notator/gui/src/main/java/gui/AppController.java:[29,45] cannot find symbol
[ERROR] symbol: class FXMLLoader
[ERROR] location: class gui.AppController


What am I doing wrong? How do I persuade Maven/Eclipse/Java/Whatever find the FXMLLoader?



The project structure has two modules, gui and logic, with the project structure in this tutorial. My overall project pom is:



<modules>
<module>logic</module>
<module>gui</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>11</source>
<target>11</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>




The pom for the gui module is:



<parent>
<groupId>com.gmail.digitig</groupId>
<artifactId>gsn-notator</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>gui</artifactId>
<dependencies>
<dependency>
<groupId>com.gmail.digitig</groupId>
<artifactId>logic</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11-ea+19</version>
</dependency>
</dependencies>


I don't have anything in the logic module yet, other than a trivial module_info.java. Class gui.AppController, where the error is being reported, is:



package gui;

import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.layout.BorderPane;

public class AppController extends BorderPane {
public AppController() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("App.fxml"));
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}


}







java maven javafx java-11 openjfx






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '18 at 4:21









nullpointer

46.3k1198189




46.3k1198189










asked Nov 18 '18 at 1:45









digitigdigitig

587626




587626








  • 1





    Few suggestions: 1. You can upgrade to the maven-compiler-plugin:3.8.0 2. You can upgrade to javafx-controls:11.0.1 3. Official sample for running JavaFX with Maven

    – nullpointer
    Nov 18 '18 at 1:55











  • Neither of the upgrades makes any difference. I have tried to align my project with the official sample, though I'm not entirely sure how to distribute it between the top level and the module. Still no change to the error - it can't find FXMLLoader. And the official sample doesn't include FXML. I had no trouble getting JavaFx apps to work with Maven until I tried to include FXML.

    – digitig
    Nov 18 '18 at 21:23














  • 1





    Few suggestions: 1. You can upgrade to the maven-compiler-plugin:3.8.0 2. You can upgrade to javafx-controls:11.0.1 3. Official sample for running JavaFX with Maven

    – nullpointer
    Nov 18 '18 at 1:55











  • Neither of the upgrades makes any difference. I have tried to align my project with the official sample, though I'm not entirely sure how to distribute it between the top level and the module. Still no change to the error - it can't find FXMLLoader. And the official sample doesn't include FXML. I had no trouble getting JavaFx apps to work with Maven until I tried to include FXML.

    – digitig
    Nov 18 '18 at 21:23








1




1





Few suggestions: 1. You can upgrade to the maven-compiler-plugin:3.8.0 2. You can upgrade to javafx-controls:11.0.1 3. Official sample for running JavaFX with Maven

– nullpointer
Nov 18 '18 at 1:55





Few suggestions: 1. You can upgrade to the maven-compiler-plugin:3.8.0 2. You can upgrade to javafx-controls:11.0.1 3. Official sample for running JavaFX with Maven

– nullpointer
Nov 18 '18 at 1:55













Neither of the upgrades makes any difference. I have tried to align my project with the official sample, though I'm not entirely sure how to distribute it between the top level and the module. Still no change to the error - it can't find FXMLLoader. And the official sample doesn't include FXML. I had no trouble getting JavaFx apps to work with Maven until I tried to include FXML.

– digitig
Nov 18 '18 at 21:23





Neither of the upgrades makes any difference. I have tried to align my project with the official sample, though I'm not entirely sure how to distribute it between the top level and the module. Still no change to the error - it can't find FXMLLoader. And the official sample doesn't include FXML. I had no trouble getting JavaFx apps to work with Maven until I tried to include FXML.

– digitig
Nov 18 '18 at 21:23












1 Answer
1






active

oldest

votes


















3














You need to include the dependency for javafx-fxml in your pom.xml:



<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.1</version>
</dependency>


and ensure the module-info.java has a requires directive for javafx.fxml module.



requires javafx.fxml;




Other suggestions:




  • You can upgrade to the maven-compiler-plugin:3.8.0


  • You can upgrade to javafx-controls:11.0.1


  • Official sample for running JavaFX with Maven







share|improve this answer


























  • Fails as before, but with an additional error: "package javafx.fxml does not exist".

    – digitig
    Nov 18 '18 at 20:02











  • @digitig I could confirm that the dependency and the module do exist and the same code as yours works for me with mvn install. Could you verify the configurations of maven in use? Just in case samples help, here is the maven module in one of my projects on GitHub and the AppController class same as yours

    – nullpointer
    Nov 19 '18 at 1:46













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357207%2fmaven-cant-find-fxmlloader%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














You need to include the dependency for javafx-fxml in your pom.xml:



<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.1</version>
</dependency>


and ensure the module-info.java has a requires directive for javafx.fxml module.



requires javafx.fxml;




Other suggestions:




  • You can upgrade to the maven-compiler-plugin:3.8.0


  • You can upgrade to javafx-controls:11.0.1


  • Official sample for running JavaFX with Maven







share|improve this answer


























  • Fails as before, but with an additional error: "package javafx.fxml does not exist".

    – digitig
    Nov 18 '18 at 20:02











  • @digitig I could confirm that the dependency and the module do exist and the same code as yours works for me with mvn install. Could you verify the configurations of maven in use? Just in case samples help, here is the maven module in one of my projects on GitHub and the AppController class same as yours

    – nullpointer
    Nov 19 '18 at 1:46


















3














You need to include the dependency for javafx-fxml in your pom.xml:



<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.1</version>
</dependency>


and ensure the module-info.java has a requires directive for javafx.fxml module.



requires javafx.fxml;




Other suggestions:




  • You can upgrade to the maven-compiler-plugin:3.8.0


  • You can upgrade to javafx-controls:11.0.1


  • Official sample for running JavaFX with Maven







share|improve this answer


























  • Fails as before, but with an additional error: "package javafx.fxml does not exist".

    – digitig
    Nov 18 '18 at 20:02











  • @digitig I could confirm that the dependency and the module do exist and the same code as yours works for me with mvn install. Could you verify the configurations of maven in use? Just in case samples help, here is the maven module in one of my projects on GitHub and the AppController class same as yours

    – nullpointer
    Nov 19 '18 at 1:46
















3












3








3







You need to include the dependency for javafx-fxml in your pom.xml:



<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.1</version>
</dependency>


and ensure the module-info.java has a requires directive for javafx.fxml module.



requires javafx.fxml;




Other suggestions:




  • You can upgrade to the maven-compiler-plugin:3.8.0


  • You can upgrade to javafx-controls:11.0.1


  • Official sample for running JavaFX with Maven







share|improve this answer















You need to include the dependency for javafx-fxml in your pom.xml:



<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11.0.1</version>
</dependency>


and ensure the module-info.java has a requires directive for javafx.fxml module.



requires javafx.fxml;




Other suggestions:




  • You can upgrade to the maven-compiler-plugin:3.8.0


  • You can upgrade to javafx-controls:11.0.1


  • Official sample for running JavaFX with Maven








share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 18 '18 at 11:11









José Pereda

25.6k34068




25.6k34068










answered Nov 18 '18 at 2:09









nullpointernullpointer

46.3k1198189




46.3k1198189













  • Fails as before, but with an additional error: "package javafx.fxml does not exist".

    – digitig
    Nov 18 '18 at 20:02











  • @digitig I could confirm that the dependency and the module do exist and the same code as yours works for me with mvn install. Could you verify the configurations of maven in use? Just in case samples help, here is the maven module in one of my projects on GitHub and the AppController class same as yours

    – nullpointer
    Nov 19 '18 at 1:46





















  • Fails as before, but with an additional error: "package javafx.fxml does not exist".

    – digitig
    Nov 18 '18 at 20:02











  • @digitig I could confirm that the dependency and the module do exist and the same code as yours works for me with mvn install. Could you verify the configurations of maven in use? Just in case samples help, here is the maven module in one of my projects on GitHub and the AppController class same as yours

    – nullpointer
    Nov 19 '18 at 1:46



















Fails as before, but with an additional error: "package javafx.fxml does not exist".

– digitig
Nov 18 '18 at 20:02





Fails as before, but with an additional error: "package javafx.fxml does not exist".

– digitig
Nov 18 '18 at 20:02













@digitig I could confirm that the dependency and the module do exist and the same code as yours works for me with mvn install. Could you verify the configurations of maven in use? Just in case samples help, here is the maven module in one of my projects on GitHub and the AppController class same as yours

– nullpointer
Nov 19 '18 at 1:46







@digitig I could confirm that the dependency and the module do exist and the same code as yours works for me with mvn install. Could you verify the configurations of maven in use? Just in case samples help, here is the maven module in one of my projects on GitHub and the AppController class same as yours

– nullpointer
Nov 19 '18 at 1:46




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53357207%2fmaven-cant-find-fxmlloader%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to pass form data using jquery Ajax to insert data in database?

National Museum of Racing and Hall of Fame

Guess what letter conforming each word