0

enter image description here

Please help me to fix this eclipse error. Actually the problem is that when i try to launch javafx in eclipse IDE compiler shows these errors, shown in the image. Although JavaFx libaray is imported code is also correct why am i still getting such errors. Please help me to fix this.

import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class HelloWorld extends Application {
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("Hello World!");
        Button btn = new Button();
        btn.setText("Say 'Hello World'");


        StackPane root = new StackPane();
        root.getChildren().add(btn);
        primaryStage.setScene(new Scene(root, 300, 250));
        primaryStage.show();
    }
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: <init>
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:288)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
    at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    ... 5 more
Caused by: java.lang.NoSuchMethodError: <init>
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
    at java.lang.Runtime.load0(Runtime.java:809)
    at java.lang.System.load(System.java:1086)
    at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:107)
    at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:39)
    at com.sun.glass.ui.gtk.GtkApplication.lambda$new$5(GtkApplication.java:156)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.glass.ui.gtk.GtkApplication.<init>(GtkApplication.java:140)
    at com.sun.glass.ui.gtk.GtkPlatformFactory.createApplication(GtkPlatformFactory.java:41)
    at com.sun.glass.ui.Application.run(Application.java:146)
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:278)
    ... 9 more
  • 5
    Note that you can easily copy&paste that stacktrace in a new code bock. This would be preferrable, since it would be a lot easier to read than a picture of the screen showing the error. Also it would contain all of the stacktrace, not just the parts that are scrolled into view. [Edit] the question! – fabian Jan 21 '20 at 06:33
  • 1
    Probably, you get this stack trace from the Java VM because in Eclipse in the project the native (JavaFX?) libraries are not or incorrectly configured. – howlger Jan 21 '20 at 08:27
  • Additionally to Fabians request, please change the title to reflect that you're having problems with JavaFX in an Eclipse project! It surely will get your question more attention of people knowing how to help you. Thank you. :-) As the E(FX)clipse plugin configures Eclipse for JavaFX, trying it out may be a step towards a solution for you. – Amadán Jan 21 '20 at 08:56
  • can you please tell me the steps how to fix this ? – Zohaib Programmer Jan 21 '20 at 15:23
  • i will be very very thankfull – Zohaib Programmer Jan 21 '20 at 15:23
  • Certainly your setup is incorrect so maybe make a screenshot or a list of which javafx components u added to your project and how you added them. – Alex Jan 22 '20 at 11:32
  • i solved this from this link. https://stackoverflow.com/questions/21185156/javafx-on-linux-is-showing-a-graphics-device-initialization-failed-for-es2-s – Zohaib Programmer Jan 23 '20 at 11:20

0 Answers0