# Java FX Injection goes wrong. Built probably wrong

**URL:** <https://discuss.gradle.org/t/java-fx-injection-goes-wrong-built-probably-wrong/40264>\
**Category:** Help/Discuss\
**Created:** [June 19, 2021, 8:18am UTC](https://discuss.gradle.org/t/java-fx-injection-goes-wrong-built-probably-wrong/40264 "2021-06-19T08:18:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![elantonio27](https://avatars.discourse-cdn.com/v4/letter/e/f08c70/32.png) [@elantonio27](https://discuss.gradle.org/u/elantonio27)\
**Post date:** [June 19, 2021, 8:18am UTC](https://discuss.gradle.org/t/java-fx-injection-goes-wrong-built-probably-wrong/40264/1 "2021-06-19T08:18:23Z")

</div>

Ok i am going to admit, this is the first time I am working with Gradle.  
But I am not new to Java itself.  
So I am trying to set up a javaFX GUI for my Project.  
I am quite sure my project isnt built perfect.  
I got a NullPointerException for all my Control-Elements…  
So here is my Code:

```gradle

plugins {
    id 'java'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.10'

}

mainClassName='newP.BKPR'
group 'newP'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

javafx {
    version = "15.0.1"
    modules = ['javafx.controls', 'javafx.fxml', 'javafx.graphics']
}

//"javafx.graphics"

sourceSets {
    main {
        resources {
            srcDirs = ["src/main/java"]
            includes = ["**/*.fxml"]
        }
    }
}
dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.8'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.8.8'
    compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.8'
    compile 'com.squareup.okhttp:okhttp:2.5.0'
    compile 'javax.mail:mail:1.4.7'
    implementation 'org.openjfx:javafx-graphics:13.0.1'

}

```

That was my gradle.built

Now follows my FX-Application:

```gradle
package newP;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javax.mail.MessagingException;
import java.io.IOException;

public class BKPR extends Application {

    private Controller controller;

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws IOException, MessagingException, InterruptedException {

        Parent root = FXMLLoader.load(getClass().getResource("View.fxml"));
        primaryStage.setTitle("Hello World");
        Scene scene = new Scene(root);
        primaryStage.setScene(new Scene(root, 300, 275));
        primaryStage.show();
        controller = new Controller(this);
    }
}

```

Well… it doesnt work.  
I always get an error on line 5 of my built.  
And i dont know why!
