2016-04-14 6 views
1

jarファイルを開くと、main/resourceフォルダにfxmlのリストが表示されますが、それでも "java.lang.NullPointerException:Location is required"が表示されます。エラー。IntelliJはjarに "java.lang.NullPointerException:Location is required"を与えています。

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()); 
      } 
     } 
    } 
+0

文字列から '../ main/resources /'を削除してみてください。 –

答えて

0

を使用する代わりに、パスを削除する必要があります私は、単純な試み提案:そのディレクトリにカレントディレクトリを検索して、貼り付ける(または絶対パスを使用して)fxmlを:

public static void main(String args[]) 
    { 
     //1. find current working dirrectory 
     System.out.println(new File(".").getAbsolutePath()); 
     //2. paste fxml's to this directory or modify ../main/.. to absolute path 
     //3. run program again? 
     launch(args); 
    } 
+1

ありがとうございました、これは私がそれが起こっていた道を見つけるのを助けました。 – user6206262

0

あなただけ/DatabaseSettingsForm.fxml

Stage stage = new Stage(); 
Parent root = FXMLLoader.load(getClass().getResource("/DatabaseSettingsForm.fxml")); 
+0

ありがとう、ちょうどこれを試して、何も変更されていません。 – user6206262

関連する問題