Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8961267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:50:59+00:00 2026-06-15T15:50:59+00:00

I am a fairly new java programmer. I only have about five weeks of

  • 0

I am a fairly new java programmer. I only have about five weeks of experience, starting from zero, and I am having problems getting javafx fxml files created in Scene Builder to load correctly if they are not in the same folder as the controller classes.

I am using

Win7x64 running jre7x86 for this build

Eclipse Juno Service Release 1
Build id: 20120920-0800

jre version 1.7.0_07

javaFx version 2.2.1-b03

SceneBuilder version 1.0-b50

My scene loader code is

private static final String RESOURCE_PATH = "/resources/";
public static Stage buildStage(@SuppressWarnings("rawtypes") Class pClass,
         String stageTitle, String resourceLocation)
   {
      Stage temp = new Stage();
      Pane page = null;
      try
      {
         page = FXMLLoader.load(pClass.getResource(RESOURCE_PATH + resourceLocation), null,
               new JavaFXBuilderFactory());
      }
      catch (IOException e)
      {
         e.printStackTrace();
      }
      Scene scene = new Scene(page);
      temp.setScene(scene);
      temp.setTitle(stageTitle);
      temp.setResizable(false);
      return temp;
   }

I know that the project directory is the /workspace/projectName/ so theoretically the loader should be able to find the files if it’s given a relative path right? The error I’m getting is

Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Location is required.
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2737)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2721)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2707)
    at outofunit.system.StageFactory.buildStage(StageFactory.java:32)
    at outofunit.desktop.ArcMaster.start(ArcMaster.java:28)
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
    ... 1 more

I’ve tried giving the loader an absolute path as well but it just isn’t accepting anything that isn’t directly in the same directory. I’m grasping at straws here trying to figure this out.

I’ve tried to research this on my own but I haven’t gotten much, the few answers on here that seemed similar didn’t seem to help, that or I am too dense and/or inexperienced to make sense of them. They are JavaFX 2.0 loading fxml files with event handlers fails and JavaFX 2.0 FXML resource loading error

A buddy of mine was able to overcome this problem by using this code

public void load(String pFileName, Stage pStage, String pTitle)
   {
      String fName = RESOURCE_PATH + pFileName;

      try
      {
         String externalForm = getClass().getResource(fName)
            .toExternalForm();

         InputStream inStream = new URL(externalForm).openStream();

         FXMLLoader loader = new FXMLLoader();
         Pane p = (Pane)loader.load(inStream);

         pStage.setTitle(pTitle);
         pStage.setScene(new Scene(p));

         mWindowControl = loader.getController();
         mWindowControl.setUp(pStage);

         pStage.show();
      }
      catch (Exception e)
      {
         e.printStackTrace();
      }
   }

The biggest difference and the reason why I haven’t been using his code is because my root pane is an Anchor pane instead of a normal pane, and his way URL instream forces a normal pane. Am I at fault for not using a normal pane as my base? I would love any help or input you guys can give. Thank you.

Edit: So I’ve been working on this problem and the error message has changed.

I changed the code to this

private final String RESOURCE_PATH = "resources/";
public void load(String pFileName, Stage pStage, String pTitle)
   {
      String fName = RESOURCE_PATH + pFileName;

      Pane page = null;

      FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(fName));

      try
      {
         page = (Pane) fxmlLoader.load();
      }
      catch (IOException exception)
      {
         throw new RuntimeException(exception);
      }

      Scene scene = new Scene(page);
      pStage.setScene(scene);
      pStage.setTitle(pTitle);

      mWindowControl = fxmlLoader.getController();
      mWindowControl.setUp(pStage);

      pStage.show();
   }

but the error I’m now getting is

java.lang.IllegalStateException: Location is not set.
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2021)
    at outofunit.desktop.WindowLoader.load(WindowLoader.java:136)
    at outofunit.desktop.WindowLoader.load(WindowLoader.java:62)
    at outofunit.desktop.ArcMaster.start(ArcMaster.java:30)
    at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
    at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
    at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
    at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
    at java.lang.Thread.run(Unknown Source)

I don’t understand how the location is not being set

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:51:01+00:00Added an answer on June 15, 2026 at 3:51 pm

    Both exceptions say “the (FXML) file you are trying to load cannot be found in the location you have provided”. Your filename is wrong or its path. Give your package structure or at least the path of class file that includes load(String pFileName, Stage pStage, String pTitle) method and the path of FXML file you want to load. Read the javadoc API of getResource() and examine sample codes about it on the net.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am fairly new to java having come from a VS2010 background. Currently working
I am fairly new to Java, and recently I was reading some material about
I have been working on Eclipse recently. I am fairly new to java programming,
I'm fairly new to Java and have a doubt that needs to be cleared.
I'm fairly new to Rational Functional Tester (Java) but I have one large blank.
I'm fairly new to Java and I've been having some difficulties with Swing. I'm
I'm fairly new to Java development, and people have been suggesting I use Eclipse
I'm fairly new to Java & Android, so I have little idea what I
I'm a fairly new programmer with some background in AS2, C#, and Java. What
Fairly new to Java, so I hope the wording makes sense. I have some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.