當打開jar文件時,我可以看到主/資源文件夾中的fxml列表,但它仍然給我「java.lang.NullPointerException:位置是必需的。」錯誤。IntelliJ to jar給「java.lang.NullPointerException:位置是必需的。」
package fxproject;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class ApplicationSplashScreen extends Application
{
Stage window;
public static void main(String args[])
{
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception
{
window = primaryStage;
loadDatabaseScreen();
window.close();
}
private void loadDatabaseScreen()
{
try
{
Stage stage = new Stage();
Parent root = FXMLLoader.load(getClass().getResource("../main/resources/DatabaseSettingsForm.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.sizeToScene();
stage.show();
}
catch(Exception e)
{
new OrchidAlertBox("Error",e.toString());
}
}
}
嘗試從字符串中刪除'../main/resources/'。 –