This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 249887

Summary: NetBeans' support of JavaFX Application classes is broken
Product: javafx Reporter: terje7601
Component: ProjectAssignee: Roman Svitanic <rsvitanic>
Status: NEW ---    
Severity: normal CC: nigjo_iqn
Priority: P3    
Version: 8.0.2   
Hardware: PC   
OS: Other   
Issue Type: DEFECT Exception Reporter:

Description terje7601 2015-01-18 22:03:33 UTC
There are several issues:

- a JavaFX Application class without a main() method is not treated as a "program entrypoint" by NetBeans: you can't do "Run/Debug/Profile File" on it and in the "Project Properties" under "Run" you can't select it as the "Main Class"

- if you create a new Maven JavaFX Application, the JavaFX Application class contains a main() method with a comment saying: "The main() method is ignored in correctly deployed JavaFX application. [...]" (see bug 212062) However, in my opinion this is simply not true. The main() method is not ignored, even for correctly deployed JavaFX applications. So that's why NetBeans should not generate the main() method at all & properly support JavaFX Application classes.
Comment 1 Lou Dasaro 2015-01-19 01:10:20 UTC
Thank you for your report.

I am unable to duplicate the anomaly you described using 
Product Version: NetBeans IDE Dev (Build 201501150001)
Java: 1.7.0_71; Java HotSpot(TM) Client VM 24.71-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_71-b14
System: Windows 8 version 6.2 running on x86; Cp1252; en_US (nb)

Please copy the information from Help->About and paste it in a comment.
Comment 2 terje7601 2015-01-19 07:56:22 UTC
Thanks for the quick feedback. Below is the requested information.

This is my environment:

Product Version: NetBeans IDE 8.0.2 (Build 201411181905)
Java: 1.8.0_25; Java HotSpot(TM) 64-Bit Server VM 25.25-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_25-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)

And for reference, below is the JavaFX Application class that gets created when creating a new Maven JavaFX Project. As you can see, the comment is there. And if I remove the main method, the class is no longer treated as a "Main Class" by NetBeans, as described in the report.

package be.groups.mavenproject1;

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;


public class MainApp extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("/fxml/Scene.fxml"));
        
        Scene scene = new Scene(root);
        scene.getStylesheets().add("/styles/Styles.css");
        
        stage.setTitle("JavaFX and Maven");
        stage.setScene(scene);
        stage.show();
    }

    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}