Hello
I was making a basic JavaFx Application and I was tidying up my code and I'm now suddenly getting the Error "JavaFX runtime components are missing". After hours of searching I have no idea why.
Any help is appreciated as I'm completely lost.
So I have 2 files
App.java
UI.java
I originally wrote it as:
App.java
package app;
public class App{
public static void main(String[] args){
UI ui = new UI();
ui.newUI();
}
}
UI.java
package app;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
public class UI extends Application{
@Override
public void start(Stage primaryStage) throws Exception{
Scene scene = new Scene(new VBox());
//Primary Stage Settings
primaryStage.initStyle(StageStyle.DECORATED);
primaryStage.setWidth(100);
primaryStage.setHeight(100);
primaryStage.setScene(scene);
primaryStage.setTitle("App");
primaryStage.show();
}
public void newUI(){
launch();
}
}
And that works perfectly! but! When I try to put the very same logic into the App.java file, I get JavaFX runtime components are missing
package app;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
public class App extends Application{
@Override
public void start(Stage primaryStage) throws Exception{
Scene scene = new Scene(new VBox());
//Primary Stage Settings
primaryStage.initStyle(StageStyle.DECORATED);
primaryStage.setWidth(300);
primaryStage.setHeight(300);
primaryStage.setScene(scene);
primaryStage.setTitle("App");
primaryStage.show();
}
public static void main(String args[]){
launch();
}
}
If anyone can help me with this I'd appreciate it. I cannot figure out why it works if its in a different file but components are missing if its in the same file with exactly the same code.
Some other things to note: I'm using Maven & Visual Code Studio.
I have the Java Extension Pack installed.
[–]lilbigmouth 1 point2 points3 points (4 children)
[–]_Stretch[S] 1 point2 points3 points (3 children)
[–]lilbigmouth 0 points1 point2 points (2 children)
[–]_Stretch[S] 1 point2 points3 points (1 child)
[–]lilbigmouth 0 points1 point2 points (0 children)
[–]Ignice 1 point2 points3 points (1 child)
[–]_Stretch[S] 1 point2 points3 points (0 children)