so I am currently working on two JavaFX Projects and on both I have following lines of Code:
package com.fire.example;
import com.fire.example.database.SQLiteDatabase;
import com.fire.example.services.BackupService;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.util.Objects;
public class FireApp extends Application {
private final BackupService backupService = new BackupService();
public static void main(String[] args) {
SQLiteDatabase sqLiteDatabase = new SQLiteDatabase();
if (sqLiteDatabase.openDBConnection()) {
sqLiteDatabase.initDB();
}
launch();
}
@Override
public void start(Stage stage) {
backupService.createBackUpFolder();
backupService.createAutomaticBackup();
backupService.deleteBackupsOlderThanOneWeek();
Platform.runLater(() -> {
try {
Parent root = FXMLLoader.load(Objects.requireNonNull(FireApp.class.getClassLoader().getResource("com.fire.example/pages/LoginPage.fxml")));
Scene loginScene = new Scene(root,1000,700);
stage.setScene(loginScene);
stage.setResizable(false);
stage.setOnCloseRequest(e -> {
Platform.exit();
System.exit(0);
});
stage.setTitle("Fire App");
stage.centerOnScreen();
stage.show();
}catch (Exception e){
e.printStackTrace();
throw new RuntimeException(e);
}
});
}
}
How ever, when I am trying to start the Project over IntelliJ IDE it works perfectly fine. But when starting either of the projects via ./gradlew run, it throws a Nullpointer at
FXMLLoader.load(Objects.requireNonNull(FireApp.class.getClassLoader().getResource("com.fire.example/pages/LoginPage.fxml")));
I get that it must have something to do with how the IDE and how gradlew loads the resources.
I have tried creating a jpackage and looking for the file structure but everything seems fine. Right now I have no ideads on how to fix this problem.
Any Help appreciated. Thanks in advance.
