11月20日開催!現年収非公開で企業からスカウトをもらってみませんか?PR

転職ドラフトでリアルな市場価値を測る。レジュメをもとに、企業から年収とミッションが提示されます。

0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

jarを実行するとjava.lang.NullPointerException: Location is required.が出る

Last updated at Posted at 2021-02-19

#エラー内容

■ビルドは通るが、jarにすると下記のエラーが出る
Caused by: java.lang.NullPointerException: Location is required.
        at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
        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 code.Main.start(Main.java:13)

■ソースの階層
src
 ∟codeフォルダー
  ∟main.class
  ∟controller.class
 ∟fxmlフォルダー
  ∟mainView.fxml

■該当のソースコード
Parent root = FXMLLoader.load(getClass().getResource("../fxml/mainView.fxml"));

#とりあえずの解決
【../fxml/mainView.fxml】
fxmlを呼び出すときに上階層だと読めない?

■ソースの構造を変える
fxmlフォルダーをcodeフォルダーの中に入れる
src
 ∟codeフォルダー
  ∟main.class
  ∟controller.class
  ∟fxmlフォルダー
   ∟mainView.fxml

コードの変更
【../】を削除する
Parent root = FXMLLoader.load(getClass().getResource("fxml/mainView.fxml"));

jarが実行できた!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Comments

No comments

Let's comment your feelings that are more than good

Qiita Advent Calendar is held!

Qiita Advent Calendar is an article posting event where you post articles by filling a calendar 🎅

Some calendars come with gifts and some gifts are drawn from all calendars 👀

Please tie the article to your calendar and let's enjoy Christmas together!

Being held Article posting campaign

0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Login to continue?

Login or Sign up with social account

Login or Sign up with your email address