Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8177294

add command line switch for JavaFX Application vs main()

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 9
    • Fix Version/s: None
    • Component/s: javafx
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      A DESCRIPTION OF THE REQUEST :
      Currently, if a class file has both a main() method and is a JavaFX Application, launching with "java <classname>" or launching similarly in jdb will always run the main() method. It would be nice if there were a command line switch to force a JavaFX-style launch in that case.


      JUSTIFICATION :
      For a JavaFX application, the main() method may be a test, or may be designed to run the program in a different way from a normal JavaFX launch.



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Launch the JavaFX application at the command line by running:

      java -javafx HelloWorld2

      or similar.
      ACTUAL -
      There is no easy way to do that when a main() method is present.


      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.layout.StackPane;
      import javafx.stage.Stage;
       
      public class HelloWorld2 extends Application {

         public static int xx = 3;
          
         Label label = new Label();

         @Override
          public void start(Stage primaryStage) {
            label.setText("Hello World");
            StackPane root = new StackPane();
            root.getChildren().add(label);
         
            Scene scene = new Scene(root, 300, 250);
         
            primaryStage.setTitle("Hello World!");
            primaryStage.setScene(scene);
            primaryStage.show();
         }
         
         
         public static void main(String[] args) {
            System.out.println("Test");
         }
      }

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: