I'm trying to export my java and javafx code as a ruunable file, but when executing the jar I get a message that says java.lang.NullPointerException: Location is required. '(You can see in the link that leaves the complete error below), the problem is that if I run the code in the same eclipse if it opens the created program without any problem, but when I export it, the jar does not open. I leave the main.java class that connects with the javafx.
On the other hand, I saw that a solution was to add getClass().getClassLoader().getResource("main.fxml") but that way I don't run the program in eclipse, so I have to leave it as getClass().getResource(" Main.fxml ")) to run in the editor.
Now, to export as a jar a java file with javafx is it exported normal or do other steps have to be followed?
public class Main extends Application {
        
        private double xOffset = 0;
        private double yOffset = 0;
        
        @Override
        public void start(final Stage stage) throws Exception {
                AnchorPane root = (AnchorPane)FXMLLoader.load(getClass().getResource("Main.fxml"));
                stage.initStyle(StageStyle.TRANSPARENT);
                Scene scene = new Scene(root);
                scene.setFill(javafx.scene.paint.Color.TRANSPARENT);
                scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
                stage.setScene(scene);
                stage.show();
                
                
                root.setOnMousePressed(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        xOffset = event.getSceneX();
                        yOffset = event.getSceneY();
                    }
                });
                
                //Permite el movimiento
                root.setOnMouseDragged(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        stage.setX(event.getScreenX() - xOffset);
                        stage.setY(event.getScreenY() - yOffset);
                    }
                });
                
                
        }
        
        public static void main(String[] args) {
            launch(args);
        }
    }
image errorImage
FOLDER Structure folder structure


