when i try to run my java file with javafx from command prompt im returned with a error, the error says the problem of the code is coming from a java launch command which i dont know how to fix. Please give a fix. the error:
Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: Main1 at javafx.graphics@19/javafx.application.Application.launch(Application.java:314) at Main1.main(Main1.java:47) Caused by: java.lang.ClassNotFoundException: Main1 at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:488) at java.base/java.lang.Class.forName(Class.java:467) at javafx.graphics@19/javafx.application.Application.launch(Application.java:302) at Main1.main(Main1.java:47) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) at java.base/java.lang.reflect.Method.invoke(Method.java:577) at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:421) at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:192) at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:132) code:
import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.web.*; import javafx.scene.image.*; public class Main1 extends Application { public void start(Stage stage) { try { stage.setTitle("Fierce Pcs"); WebView w = new WebView(); WebEngine e = w.getEngine(); e.load("https://www.example.com/"); stage.getIcons().add(new Image(getClass().getResourceAsStream("icon.png"))); Scene scene = new Scene(w, w.getPrefWidth(), w.getPrefHeight()); stage.setScene(scene); stage.show(); } catch (Exception e) { System.out.println(e.getMessage()); } } public static void main(String args[]) { launch(args); } } the command which i give the command prompt:
java --module-path %PATH_TO_FX% --add-modules javafx.fxml,javafx.web C:\Users\example\OneDrive\Desktop\Main1.java