Major Ben
Major Ben

Reputation: 139

JavaFX: application Launch Must not be called more than once

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

Answers (1)

Irshad Babar
Irshad Babar

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

Related Questions