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 Build a Pomodoro App Build the State Change Events

kalyada leosrisook
kalyada leosrisook
Courses Plus Student 17,855 Points

how do I solve this nullException in main method ?

When I tried to run the main method for the pomodoro application it throws a nullException. The problem is on the line 15 :

public class Main extends Application {

    public void start(Stage primaryStage) throws Exception {
        // Load the font
        Font.loadFont(getClass().getResource("/fonts/VarelaRound-Regular.ttf").toExternalForm(), 10);
        Parent root = FXMLLoader.load(getClass().getResource("/fxml/home.fxml"));

(the problem is on the Font.loadFont....)

I dont know how to fix it. I tried being specific on the path but it doesnt help. could anyone help me out here so I can move on? thank you

Robin Damsgaard Larsen
Robin Damsgaard Larsen
13,929 Points

I think I know what's going on. Try marking the "resources" directory as an actual Resources directory that IntelliJ understands.

For this, go into File -> Project Structure... -> Modules. Then click the "resources" directory in the list, then hit "Resources" in the "Mark as:" bar.