Search code examples
javajavafx-8maven-3resourcebundlefxmlloader

Unable to load ResourceBundle with ResourceBundle.getBundle() Can't find bundle for base name , locale en_US


I see the following exception when I try to load a properties file:

Caused by: java.util.MissingResourceException: Can't find bundle for base name /fontawesome/fontawesome, locale en_US

I'm using a maven project and my properties file is located at src\main\resources\fontawesome\fontawesome.properties

I'm using the below code to load this file from JavaFX8 main class:

FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setResources(ResourceBundle.getBundle("/fontawesome/fontawesome.properties"));

Trying the absolute path fails, as does renaming the file to fontawesome_en_US.properties or fontawesome_en.properties (as suggested in other SO posts).


Solution

  • Had to include .properties files in the pom.xml:

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*.fxml</include>
                <include>**/*.css</include>
                <include>**/*.properties</include>
            </includes>
        </resource>
    </resources>