Reputation: 139
I am new to JavaFX and I was just typing some code...but whenever I try to run the application the second time I get an error stating: application launch must not be called more than once:
My first code was:
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.application.*;
public class App extends Application{
public void start (Stage primaryStage){
primaryStage.setTitle("Chess");
primaryStage.show();
}
public static void main(String args[]){
Application.launch (args);
}
}
then after doing some search I changed it to:
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.application.*;
public class App extends Application{
public void start (Stage primaryStage){
Platform.setImplicitExit(true);
primaryStage.setTitle("Chess");
primaryStage.show();
}
public static void main(String args[]){
Application.launch (args);
}
}
But it still shows the same error:
java.lang.IllegalStateException: Application launch must not be called more than once
Upvotes: 2
Views: 3807
Reputation: 1419
Why you are adding
Platform.setImplicitExit(true); it is by default true, you don't need to call main method, just compile and run your application.
Upvotes: 1