-2

当我尝试在 NetBeans 上运行来自 EmojiOneJava 的代码时,我一直遇到错误。这是别人的代码,我想看看它是如何工作的。我需要帮助在 NetBeans 中或通过 GitBash 运行此代码(我使用的是 Windows 计算机)

链接到 GitHub 存储库:https ://github.com/UltimateZero/EmojiOneJava

我遇到的错误示例:

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$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:748)
 Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at com.uz.emojione.fx.EmojiListExample.start(EmojiListExample.java:24)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191)
... 1 more

异常运行应用程序 com.uz.emojione.fx.EmojiListExample Java 结果:1

4

1 回答 1

0

第一的:

将您的两个文件与它们的控制器一起重构FXML到文件夹中。用和fx做同样的事情。将这些重构到文件夹中。emoji.jsonJson.javaemojione

新项目结构

第二:

//The correct way to load and Image:


private String getEmojiImagePath(String hexStr)
{
    String filePath = "resources/com/uz/emojione/fx/png_40/" + hexStr + ".png";
    File file = new File(filePath);

    return file.toURI().toString();
}

第三:

转到您的src文件夹并剪切resources文件夹。resources现在将文件夹粘贴到与src

在此处输入图像描述

最后:您必须将该文件夹部署在与您在 Netbeans 外部运行的resources文件夹相同的文件夹中。jar

在此处输入图像描述

我注意到你也有这个:

在此处输入图像描述

为了让它运行,我必须做同样的事情来加载我上面做的图像。

于 2017-11-28T19:26:19.537 回答