I have created and complied several javaFX applications without main methods in NetBeans and InteliJ IDEA. I have also compiled successfully a simple JavaFX application (see the code below) without a main method in windows command line.
import javafx.application.Application;
import javafx.stage.Stage;
public class HelloJavaFX extends Application{
@Override
public void start(Stage stage){
stage.setTitle("Hello JavaFX");
stage.show();
}
}
So I believe it is possible to run JavaFX applications without main methods in eclipse too. But when I try it, I fail and eclipse indicates could not find a main method. I have added JavaFX jar file to my eclipse IDE and I can compile and run JavaFX applications with main methods in eclipse. So I guess I should add some path or address to help eclipse to run it, but I don't know how.
My question is "what else should I do to make eclipse compile and run JavaFX applications without main method?"
Actually reading the question " Can't run JavaFx code from Eclipse" and its answers helped me to figure out how to run a JavaFX application without main method. First we add the main method and run it once as follows:
public static void main(String[] args) {
Application.launch(args);
}
Then we comment the main method out. Now the eclipse IDE run configuration is automatically set to run the application even without the main method.
Thanks @Oleg for directing me to the abovementioned question. Now, if nobody has any other answer, I announce the question as duplicate.