Caused by: java.util.MissingResourceException: Can't find bundle for base name ..bundles.Locale

Viewed 37

Fxml files sees. Put an fxml folder with files todolist.xml , todolistedit.xml (folder resources), write FXMLLoader.setLocation(getClass().getResource("/fxml/todolist.fxml")); clean -> package - > fxml files appeared in the target. My name bundle TestBundle He's looking for some old way, I've already changed it. Text error:Caused by: java.util.MissingResourceException: Can't find bundle for base name ru.todolist.javafx.bundles.Locale, locale ru.

assembly folder:

enter image description here

public class Main extends Application {

    private static Locale DEFAULT_LOCALE = new Locale("en");

    @Override
    public void start(Stage stage) throws Exception {

        Locale.setDefault(DEFAULT_LOCALE);

        FXMLLoader fxmlLoader = new FXMLLoader();

     //   fxmlLoader.setLocation(getClass().getResource("../fxml/todolist.fxml"));
        fxmlLoader.setLocation(getClass().getResource("/fxml/todolist.fxml"));
        fxmlLoader.setResources(ResourceBundle.getBundle("TestBundle_ru", new Locale("ru")));

        Parent fxmlMain = fxmlLoader.load();
        MainController mainController = fxmlLoader.getController();
        mainController.setMainStage(stage);

        stage.setTitle(fxmlLoader.getResources().getString("todo_list"));
        stage.setMinHeight(650);
        stage.setMinWidth(750);
        stage.setScene(new Scene(fxmlMain, 650, 675));
        stage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}

Program hierarchy Program hierarchy

I tried the options, moved the resource to the folder and where is the whole project in general:

fxmlLoader.setResources(ResourceBundle.getBundle("TestBundle"));; //or
fxmlLoader.setResources(ResourceBundle.getBundle("TestBundle_ru"));;// or 
fxmlLoader.setResources(ResourceBundle.getBundle("TestBundle", new Locale("ru))); // or

error:

   Exception in Application start method

java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:465) at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1051) Caused by: java.lang.RuntimeException: Exception in Application start method at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901) at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.util.MissingResourceException: Can't find bundle for base name TestBundle_ru.properties, locale ru at java.base/java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:2055) at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1689) at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1593) at java.base/java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1556) at java.base/java.util.ResourceBundle.getBundle(ResourceBundle.java:932) at ru.todolist.javafx.start.Main.start(Main.java:26) at javafx.graphics@18.0.1/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847) at javafx.graphics@18.0.1/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484) at javafx.graphics@18.0.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics@18.0.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456) at javafx.graphics@18.0.1/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96) at javafx.graphics@18.0.1/com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at javafx.graphics@18.0.1/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184) ... 1 more Exception running application ru.todolist.javafx.start.Main

0 Answers
Related