-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
9
-
x86_64
-
windows_7
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 ----------
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 ----------
- relates to
-
JDK-8102035 Change launcher to always call the main method for standalone JavaFX applications
- Resolved