javajavafxemojiemojione

Running EmojiOneJava on NetBeans


I keep running into errors when I try to run the code from EmojiOneJava on NetBeans. It's someone else's code and I want to see how it'll work. I need help either running this code in NetBeans or via GitBash (I used a Windows computer)

Link to GitHub repository: https://github.com/UltimateZero/EmojiOneJava

Example of error I encounter:

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

Exception running application com.uz.emojione.fx.EmojiListExample Java Result: 1


Solution

  • First:

    Refactor both of your FXML files into the fx folder with their controllers. Do the same thing with emoji.jsonand Json.java. Refactor those to the emojione folder.

    New Project Structure

    Second:

    //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();
    }
    

    Third:

    Go to your src folder and cut the resources folder. Now paste the resources folder into the same folder as src

    enter image description here

    Finally: You will have to deploy the resources folder in the same folder as your jar to run this outside of Netbeans.

    enter image description here

    I notice that you also have this:

    enter image description here

    To get this running I had to do the same thing with loading the images that I did above.