java – Is it possible to run the start method without using launch?

Question:

To run the start() method in javafx, you need to write Application.launch(args) in main() Application.launch(args) . This must be done in a class in which the start() method is overridden. What if I want to run javafx from another class? In the class where start overridden, I wrote the reLaunch(String[] args) method, in which I wrote Application.launch(args) . Then, from another class from the main() method, I called reLaunch. But it still doesn't work.

PS As I understand it, you won't be able to run launch() in a class that does not have main() , because of args . Is there a way to run without args ?

class Clock extend Application {
   ... reLaunch(String[] args) { Application.launch(args) }
}

class Start {
   ... main(...) {
   Clock clock = new Clock(); clock.reLaunch(args);
   }
}

Answer:

You need to pass a class inherited from Application to the launch method. Because FX starts from the same class, it will be launch (Clock.class). I'm not sure if you need to create a Cloak instance for this at all. Application.launch (Clock.class) might work.

Scroll to Top
AllEscort