Error on javafx
Anouchka2586
Posted messages
47
Registration date
Status
Member
Last intervention
-
Anouchka2586 Posted messages 47 Registration date Status Member Last intervention -
Anouchka2586 Posted messages 47 Registration date Status Member Last intervention -
Hello,
I have this error with the code below:
Error: Could not find or load main class application.Main
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
Thank you for your help!
I have this error with the code below:
Error: Could not find or load main class application.Main
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application
package application; import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.shape.Rectangle; import javafx.scene.shape.Shape; public class Main extends Application { @Override public void start(Stage primaryStage) { try { Group root = new Group(); Scene scene = new Scene(root,800,800); Shape s = new Shape(); Rectangle r = new Rectangle(); r.setX(750); r.setY(100); r.setWidth(200); r.setHeight(100); r.setArcWidth(30); r.setArcHeight(20); root.getChildren().add(r); primaryStage.setScene(scene); primaryStage.setTitle("Hello world"); primaryStage.show(); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) { launch(args); } } Thank you for your help!
3 answers
Hello,
Which version of Java are you coding with?
Since Java 11, Java FX is no longer included in the JDK; it is managed separately, as was already the case before Java 8.
See https://openjfx.io
--
Trust does not exclude control.
Which version of Java are you coding with?
Since Java 11, Java FX is no longer included in the JDK; it is managed separately, as was already the case before Java 8.
See https://openjfx.io
--
Trust does not exclude control.
I am on version 14. I followed this tutorial: https://openjfx.io/openjfx-docs/ to install JavaFX but I have this error:
Error: Could not find or load main class Files
Caused by: java.lang.ClassNotFoundException: Files
Error: Could not find or load main class Files
Caused by: java.lang.ClassNotFoundException: Files
It seems that this is related to the installation directory
Generally, we put quotes around a path that contains spaces. In this particular case, we could use
C:/Program Filesbecause of the space.
Generally, we put quotes around a path that contains spaces. In this particular case, we could use
C:/PROGRA~1which is an alias. Otherwise, you can try with an installation in a directory without spaces.