Problem with running a JavaFX project on Netbeans 12.4

I am able to run: FXMLJavaFXMaven Archetype and SimpleJavaFXMavenArchetype provided by Natebeans 12.4. Now I created the application using following steps:

File-→NewProject-→ Java with Maven and Java Application-→ProjectName(JavaFx2) and then I right clicked on javafx2 from the project list-→New-→other-→JavaFX2 (Frome categories) and File Types(JavaFxMain Class)-→Next-→ClassName(Fx2FXMain) and Package(com.mycompany.javafx2)-→finish, I got following code with full of red balls (i.e. errors):

import javafx.application.Application;//err package not exist
import javafx.event.ActionEvent;//err package not exits and so in all import declaration
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;


  • @author zulfi
    public class Fx2FXMain extends Application {

    public void start(Stage primaryStage) {
    Button btn = new Button();
    btn.setText(“Say ‘Hello World’”);
    btn.setOnAction(new EventHandler() {

         public void handle(ActionEvent event) {
             System.out.println("Hello World!");
     StackPane root = new StackPane();
     Scene scene = new Scene(root, 300, 250);
     primaryStage.setTitle("Hello World!");



    • @param args the command line arguments
      public static void main(String args) {


All import instructions are giving the error, package does not exits. Somebody please guide me.