0

Доброго времени суток. Подключил Maven к проекту и теперь MainCompare класс не может подгрузить fxml файл. Пробовал и

Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("MainView.fxml"));

и

Parent root = FXMLLoader.load(getClass().getResource("MainView.fxml"));

Переместил в директорию класса, всё равно не помогает, вылетает NullPointerException: Location is required.

Подскажите, как быть в данной ситуации?

1 ответ 1

1

Положите Ваш файл MainView.fxml в папку resources maven проекта и получайте его так:

    Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("/MainView.fxml"));

или

  Parent root = FXMLLoader.load(getClass().getResource("/MainView.fxml"));  
2
  • Большое спасибо!:)
    – Антон
    21 мар 2018 в 7:17
  • Если подсказка помогла, отметьте как ответ. Спасибо )
    – ezhov_da
    21 мар 2018 в 7:19

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.