Koshkasobaka
@Koshkasobaka

Почему возникает ошибка при запуске кода на javafx?

Здравствуйте, не понимаю почему выдает ошибку, путь к файлу указан правильно. Помогите, пожалуйста, разобраться
Код:
package com.example.sudoku;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class SudokuApp extends Application {


    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("/com/example/sudoku/fxml/start.fxml"));
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.setTitle("СУДОКУ");
        stage.setResizable(true);
        stage.show();
    }


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


И ошибка:

Exception in Application start method
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
	at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
	at java.lang.Thread.run(Thread.java:748)
Caused by: javafx.fxml.LoadException: 
/C:/Users/1/IdeaProjects/Sudoku/out/production/Sudoku/com/example/sudoku/fxml/start.fxml

	at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2601)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2579)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2441)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3214)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
	at com.example.sudoku.SudokuApp.start(SudokuApp.java:14)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
	at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
	... 1 more
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 1
	at java.lang.String.substring(String.java:1963)
	at com.example.sudoku.logic.hidecells.solvers.ColumnPair.removeDigits(ColumnPair.java:49)
	at com.example.sudoku.logic.hidecells.solvers.ColumnPair.findPairs(ColumnPair.java:30)
	at com.example.sudoku.logic.hidecells.solvers.ColumnPair.tryToSolve(ColumnPair.java:14)
	at com.example.sudoku.logic.hidecells.CellHider.checkSudoku(CellHider.java:99)
	at com.example.sudoku.logic.hidecells.CellHider.selectCell(CellHider.java:62)
	at com.example.sudoku.logic.hidecells.CellHider.makeBoardWithHiddenCells(CellHider.java:24)
	at com.example.sudoku.logic.SudokuGenerator.lambda$fillStorage$0(SudokuGenerator.java:52)
	at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
	at com.example.sudoku.logic.SudokuGenerator.fillStorage(SudokuGenerator.java:48)
	at com.example.sudoku.logic.Initializer.init(Initializer.java:41)
	at com.example.sudoku.logic.Initializer.getInstance(Initializer.java:30)
	at com.example.sudoku.controller.StartController.initialize(StartController.java:41)
	at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
	... 17 more
Exception running application com.example.sudoku.SudokuApp
  • Вопрос задан
  • 21 просмотр
Решения вопроса 1
@Cheypnow
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 1
  at java.lang.String.substring(String.java:1963)
  at com.example.sudoku.logic.hidecells.solvers.ColumnPair.removeDigits(ColumnPair.java:49)
  at com.example.sudoku.logic.hidecells.solvers.ColumnPair.findPairs(ColumnPair.java:30)
  at com.example.sudoku.logic.hidecells.solvers.ColumnPair.tryToSolve(ColumnPair.java:14)

Где-то вызывается substring на пустой строке. Из приведенного кода не понятно в чем именно проблема, но где-то на 49 строке класса ColumnPair.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы