HanSolo / medusa

A JavaFX library for Gauges
Apache License 2.0
694 stars 131 forks source link

java.lang.NoClassDefFoundError: eu/hansolo/medusa/Gauge #193

Closed BigFish90 closed 4 years ago

BigFish90 commented 4 years ago

Hello sir, I use : Eclipse IDE for Java Developers Version: 2019-12 (4.14.0) Build id: 20191212-1212

What should i do?

I have tried to use different versions of medusa.jar (8.0, 8.3, 11.1, 11.3) with differents jre (8, 9, 10), but i get in the consol almost same error:

Exception in Application start method java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:473) at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:372) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:945) Caused by: java.lang.RuntimeException: Exception in Application start method at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:973) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:198) at java.base/java.lang.Thread.run(Thread.java:844) Caused by: java.lang.NoClassDefFoundError: eu/hansolo/medusa/Gauge at medusaguage.MedusaGuage.start(MedusaGuage.java:29) at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:919) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(PlatformImpl.java:449) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418) at java.base/java.security.AccessController.doPrivileged(Native Method) at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417) 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:175) ... 1 more Caused by: java.lang.ClassNotFoundException: eu.hansolo.medusa.Gauge at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496) ... 10 more Exception running application medusaguage.MedusaGuage

HanSolo commented 4 years ago

Could you please provide a code example of what you have tried so that I can reproduce it please? To run Medusa 11 you need for example OpenJDK11 in combination with OpenJFX from Gluon.

BigFish90 commented 4 years ago

Hello HanSolo, the code is below:

`import eu.hansolo.medusa.Gauge;

import eu.hansolo.medusa.GaugeBuilder; import eu.hansolo.medusa.TickLabelOrientation; import eu.hansolo.medusa.skins.ModernSkin; import eu.hansolo.medusa.skins.SpaceXSkin; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.stage.Stage;

/*

} `

HanSolo commented 4 years ago

Your code works fine, so the problem seems to be related to your JavaFX setup. Please check openjfx.io to make sure your setup of OpenJDK + OpenJFX is correct. I've also modified your code a bit so that is makes use of the GaugeBuilder.

import eu.hansolo.medusa.Gauge.SkinType;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class Test extends Application {
    private Gauge  gauge;
    private Button btn;

    @Override public void init() {
        gauge = GaugeBuilder.create()
                            .skinType(SkinType.MODERN)
                            .title("COOL IT HELP")  //title
                            .unit("Km / h")  //unit
                            .unitColor(Color.WHITE)
                            .decimals(0)
                            .value(50.00) //deafult position of needle on gauage
                            .animated(true)
                            //.animationDuration(500)
                            .valueColor(Color.WHITE)
                            .titleColor(Color.WHITE)
                            .subTitleColor(Color.WHITE)
                            .barColor(Color.rgb(0, 214, 215))
                            .needleColor(Color.RED)
                            .thresholdColor(Color.RED)  //color will become red if it crosses thereshold value
                            .threshold(85)
                            .thresholdVisible(true)
                            .tickLabelColor(Color.rgb(151, 151, 151))
                            .tickMarkColor(Color.WHITE)
                            .tickLabelOrientation(TickLabelOrientation.ORTHOGONAL)
                            .build();

        btn = new Button("Say 'Hello World'");
        btn.setTranslateX(10);
        btn.setTranslateY(200);

        //button click action handler
        btn.setOnAction(event -> {
            System.out.println("Hello World!");
            gauge.setValue(90.00);
        });
    }

    @Override public void start(Stage primaryStage) {
        StackPane root = new StackPane(gauge, btn);
        Scene scene = new Scene(root, 300, 250);

        primaryStage.setTitle("Gauge Example");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Gauge Example 2020-07-08 20-39-21 Gauge Example 2020-07-08 20-39-32

HanSolo commented 4 years ago

Closed because the problem is not related to Medusa but to the JavaFX setup