I got a problem that I absolutely can't solve on my own because I have just started using JAVA FX. help me please. the error
javafx.fxml.LoadException:
/C:/Users/DELL/eclipse-workspace/RiadFxProject/bin/application/RiadFxml.fxml
at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2714)
at javafx.fxml/javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2986)
at javafx.fxml/javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2830)
at javafx.fxml/javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2765)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2631)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2555)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3368)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3324)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3292)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3264)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3240)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3233)
at RiadFxProject/application.Main.start(Main.java:24)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:1589)
Caused by: java.lang.ClassNotFoundException: com.gluonhq.charm.glisten.control.Avatar
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 javafx.fxml/javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:3054)
at javafx.fxml/javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:3043)
at javafx.fxml/javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2984)
... 20 more
main.java
package application;
import javafx.scene.text.*;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String []args)
{
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
// TODO Auto-generated method stub
//Group root=new Group();
try {
AnchorPane root = (AnchorPane) FXMLLoader.load(Main.class.getResource("/application/RiadFxml.fxml"));
Scene scene=new Scene(root,400,400);
stage.setScene(scene);
stage.show();
}catch(Exception e)
{
e.printStackTrace();
}
}
}
RiadFxml.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import com.gluonhq.charm.glisten.control.Avatar?>
<?import com.gluonhq.charm.glisten.control.BottomNavigationButton?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.shape.Arc?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller=".FXMLController">
<children>
<Avatar layoutX="47.0" layoutY="52.0" />
<BottomNavigationButton layoutX="397.0" layoutY="39.0" />
<Arc fill="DODGERBLUE" layoutX="126.0" layoutY="200.0" length="270.0" radiusX="100.0" radiusY="100.0" startAngle="45.0" stroke="BLACK" strokeType="INSIDE" type="ROUND" />
<Button layoutX="222.0" layoutY="188.0" mnemonicParsing="false" text="Button" />
<Button layoutX="353.0" layoutY="188.0" mnemonicParsing="false" text="Button" />
</children>
</AnchorPane>
I tried some of the solutions previously suggested here. I followed the steps of Pro Code on YouTube, but the problem was not solvedI tried some of the solutions previously suggested here. I followed the steps of Pro Code on YouTube, but the problem was not solved
Solution
If you are new to JavaFX I recommend you to check out this preconfigured non modular project and configure it to your needs:
https://github.com/davidweber411/SimpleJavaFxAppWithoutModules
Just download, extract, start, profit! Everything ist configured out of the box!
Alternative
You can create a running JavaFX project with this project generator:
GitHub link:
https://github.com/davidweber411/JavaFxProjectGenerator
Homepage:
https://wedasoft.com/projects/javafx-project-generator/#
Note
I am the author of both.
There is a gradle task for creating am executable fat jar.