Исключение в методе запуска приложения. java .lang.reflect.InvocationTargetException javafx8 - PullRequest
0 голосов
/ 30 марта 2020

Я получаю эту ошибку, и я не могу понять, что именно не так. Это работало очень хорошо три дня go, и теперь я не могу его запустить. Я вижу, что возникают проблемы с URL-адресом изображения, но я дважды проверил URL-адрес и попробовал альтернативный вариант без удачи. Я не понимаю, почему он работал несколько дней go, когда я ничего не менял.

Вот код:

public class MCobbM10A2 extends Application {
    @Override
    public void start(Stage primaryStage) {
        Pane pane = new Pane();
        ImageView imageView = new ImageView("images/Black_Cat.png");
        imageView.setFitHeight(100);
        imageView.setFitWidth(100);
        pane.getChildren().add(imageView);
        PathTransition pt1 = new PathTransition(Duration.millis(2000)
            ,new Line(100, 100, 750, 500), imageView);
        pt1.setInterpolator(Interpolator.LINEAR);
        PathTransition pt2 = new PathTransition(Duration.millis(500)
            ,new Line(750, 500, 600, 550), imageView);
        pt2.setInterpolator(Interpolator.LINEAR);
        PathTransition pt3 = new PathTransition(Duration.millis(1600)
            ,new Line(600, 550, 50, 150), imageView);
        pt3.setInterpolator(Interpolator.LINEAR);
        PathTransition pt4 = new PathTransition(Duration.millis(360)
            ,new Line(50, 150, 100, 100), imageView);
        pt3.setInterpolator(Interpolator.LINEAR);
        SequentialTransition s = new SequentialTransition(pt1, pt2, pt3, pt4);
        s.play();
        Scene scene = new Scene(pane, 800, 600);
        primaryStage.setTitle("Cat Move");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
     /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
}

Вот трассировка стека:

Executing C:\Users\cmatt\Desktop\MCobbM10A2\dist\run1883417844\MCobbM10A2.jar using platform C:\Program Files\Java\jdk1.8.0_241\jre/bin/java
Exception in Application start method
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 com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    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: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Invalid URL: Invalid URL or resource not found
    at javafx.scene.image.Image.validateUrl(Image.java:1118)
    at javafx.scene.image.Image.<init>(Image.java:620)
    at javafx.scene.image.ImageView.<init>(ImageView.java:166)
    at mcobbm10a2.MCobbM10A2.start(MCobbM10A2.java:22)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
    ... 1 more
Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found
    at javafx.scene.image.Image.validateUrl(Image.java:1110)
    ... 12 more
Exception running application mcobbm10a2.MCobbM10A2
Java Result: 1

РЕДАКТИРОВАТЬ: Вот новая ошибка:

C:\Users\cmatt\OneDrive - Lincoln Land Community College\Spring 2020\CSC 176\Netbeans Projects\MCobbM10A2\nbproject\jfx-impl.xml:3867: The following error occurred while executing this line:
C:\Users\cmatt\OneDrive - Lincoln Land Community College\Spring 2020\CSC 176\Netbeans Projects\MCobbM10A2\nbproject\jfx-impl.xml:3904: The following error occurred while executing this line:
C:\Users\cmatt\OneDrive - Lincoln Land Community College\Spring 2020\CSC 176\Netbeans Projects\MCobbM10A2\nbproject\build-impl.xml:1134: Directory C:\Users\cmatt\OneDrive - Lincoln Land Community College\Spring 2020\CSC 176\Netbeans Projects\MCobbM10A2\dist creation was not successful for an unknown reason
BUILD FAILED (total time: 1 second)
...