Issue
I'm trying to load a .properties
file into my ResourceBundle
public class Main extends Application {
@Override
public void start(Stage stage) throws Exception{
ResourceBundle bundle = ResourceBundle.getBundle("/sample/resources/language_en.properties");
FXMLLoader loader = new FXMLLoader(getClass().getResource("/sample/layout/test_form.fxml"), bundle);
}
}
But I'm getting the error:
Caused by: java.util.MissingResourceException: Can't find bundle for base name /sample/resources/language_en.properties, locale en_US
Can't figure out why. I've checked the path multiple times /sample/resources/language_en.properties
for spelling mistakes. I've also tried rebuilding the project (Using IntelliJ).
Does anyone have an idea why?
Solution
When loading resource bundle don't have .properties
in basename extensions. Also, remove the leading /
for the basename.
Use ResourceBundle bundle = ResourceBundle.getBundle("sample/resources/language_en");
Answered By - Karthikeyan
Answer Checked By - Terry (JavaFixing Volunteer)