title: Why isn't my image visible when using javafx?
body: <p>Whenever I run it, it shows an error because it can't find the file.</p>
  <p>This is with intelliJ, I've tried many solutions but they aren't working.</p>
  <p>Someone replied before but I'm pretty sure I did their fix wrong because before it was showing a blank part where the image should be, but now it is giving me errors.</p>
  <p><a href="https://i.stack.imgur.com/kvkUn.png" rel="nofollow noreferrer">Library</a></p>
  <pre><code>package GUI;
  
  import javafx.application.Application;
  import javafx.geometry.Pos;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.stage.Stage;
  import javafx.scene.layout.VBox;
  import javafx.scene.image.Image;
  import javafx.scene.image.ImageView;
  
  import java.io.File;
  import java.util.Objects;
  
  public class GameGUI extends Application{
      @Override
      public void start(Stage primaryStage) {
          //Sets the stage
          //Stage Menu = new Stage();
  
          //Cheske Pic
          Image cheske = new Image(getClass().getResourceAsStream(&quot;src/main/resources/CheskePic.png&quot;));
          ImageView cheskePic = new ImageView(cheske);
          cheskePic.setFitHeight(200);
          cheskePic.setFitWidth(200);
  
          //Choose Pieces Button
          Button Pieces = new Button(&quot;Choose Your Pieces&quot;);
          Pieces.setOnAction(e -&gt; {
              //Edit the 2-D Array
          });
  
          //Start Game Button
          Button Start = new Button(&quot;Start&quot;);
          Start.setOnAction(e -&gt; {
              //BoardGUI.show();
          });
  
          //Quit Game Button
          Button Quit = new Button(&quot;Quit&quot;);
          Quit.setOnAction(e -&gt; {
              primaryStage.close();
          });
  
          //Sets the layout with all the buttons / pic
          VBox layout = new VBox(10);
          layout.getChildren().addAll(cheskePic,Pieces,Start,Quit);
          layout.setAlignment(Pos.CENTER);
  
          //Sets the scene with the layout we have given it
          Scene scene = new Scene(layout, 400, 400);
  
          //Sets all stage settings then shows the Menu
          primaryStage.setTitle(&quot;Hello!&quot;);
          primaryStage.setScene(scene);
          primaryStage.show();
      }
      public static void main(String[] args){
          launch();
      }
  }
  </code></pre>