Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Build a JavaFX Application Design a Better App Resources

Tomas Verblya
Tomas Verblya
1,998 Points

Could someone clarify the path to the resource?

When loading the FXML

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

Why does the getResource() method start looking at /fxml/.

when the Main.java (which is using that line) is in root directory. The FXML file is in /resources/fxml/sample.fxml

why don't we need to start the root directory ? what points it there?

1 Answer

Boban Talevski
Boban Talevski
24,793 Points

At around 01:57 in the video, Craig right clicks the newly created resources folder, and selects Mark Directory As -> Resources Root, which is what makes this the default resource directory.