0

I have been trying to create an app using JavaFX, JavaFX fxml application on Netbeans, I'm using java 8, and Javafx SDK 20, the output shows build successful, but the exe doesn't show up.

This is the output code. I don't understand what is the issue and no idea how to fix it.

ant -f C:\Users\youse\hotelManagementProject jfxsa-runjfxsa-run:Buildfile: C:\Users\youse\hotelManagementProject\build.xml
-mark-project-state-running:
-check-jfxrt-in-fxsdk-jre:
-set-jfxrt-in-fxsdk-jre-old:
-set-jfxrt-in-fxsdk-jre-new:
-check-jfxrt-in-fxsdk-rt:
-set-jfxrt-in-fxsdk-rt-old:
-set-jfxrt-in-fxsdk-rt-new:
-check-jfxrt-in-platform-home-jre:
-set-jfxrt-in-platform-home-jre-old:
-set-jfxrt-in-platform-home-jre-new:
-check-jfxrt-in-platform-home-rt:
-set-jfxrt-in-platform-home-rt-old:
-set-jfxrt-in-platform-home-rt-new:
-check-jfxrt-modules-in-platform-home:
-set-jfxrt-modules-in-platform-home:
-check-jfxrt-in-jre:
-set-jfxrt-in-jre-old:
-set-jfxrt-in-jre-new:
-set-jfxrt-in-jre-mods:
-check-jfxrt-in-envjdk-jre:
-set-jfxrt-in-envjdk-jre-old:
-set-jfxrt-in-envjdk-jre-new:
-check-jfxrt-modules-in-envjdk:
-set-jfxrt-modules-in-envjdk:
-pre-check-jfx-runtime:
-check-jfx-runtime:
-check-project:
-warn-of-preloader:
-post-init:
-init-check:
-init-ap-cmdline-properties:
-init-macrodef-modulename:
-init-source-module-properties:
-init-macrodef-javac-with-module:
-init-macrodef-javac-with-processors:
-init-macrodef-javac-without-processors:
-init-macrodef-javac:
-init-macrodef-test-impl:
-init-macrodef-junit-init:
-init-test-properties:
-init-macrodef-junit-prototype-with-module:
-init-macrodef-junit-prototype-without-module:
-init-macrodef-junit-single:
-init-macrodef-junit-batch:
-init-macrodef-junit:
-init-macrodef-junit-impl:
-init-macrodef-testng:
-init-macrodef-testng-impl:
-init-macrodef-test:
-init-macrodef-junit-debug-impl:
-init-macrodef-test-debug-junit:
-init-macrodef-testng-debug:
-init-macrodef-testng-debug-impl:
-init-macrodef-test-debug-testng:
-init-macrodef-test-debug:
-init-debug-args:
-init-macrodef-nbjpda:
-init-macrodef-debug:
-init-macrodef-java-with-module:
-init-macrodef-java-with-unnamed-module:
-init-macrodef-java-without-module:
-init-macrodef-java:
-init-presetdef-jar:
-init-ap-cmdline-supported:
-init-ap-cmdline:
init:
-deps-jar-init:[delete] Deleting: C:\Users\youse\hotelManagementProject\build\built-jar.properties
deps-jar:
-warn-already-built-jar:[propertyfile] Updating property file: C:\Users\youse\hotelManagementProject\build\built-jar.properties
-check-automatic-build:
-clean-after-automatic-build:
-verify-automatic-build:
-pre-pre-compile:
-pre-compile:
-copy-persistence-xml:
-compile-depend:
-do-compile:
-post-compile:
compile:
-pre-jar:
-check-module-main-class:
-set-module-main-class:
-pre-pre-jar:
-do-jar-create-manifest:
-do-jar-copy-manifest:
-do-jar-set-mainclass:
-do-jar-set-profile:
-do-jar-set-splashscreen:
-check-do-mkdist:
-do-jar-jar:
-init-macrodef-copylibs:
-do-jar-copylibs:
-do-jar-delete-manifest:
-do-jar-without-libraries:
-do-jar-with-libraries:
-jfx-copylibs-warning:
-jfx-copylibs:[delete] Deleting directory C:\Users\youse\hotelManagementProject\dist\lib[copy] Copying 1 file to C:\Users\youse\hotelManagementProject\dist\lib
-check-rebase-libs:
-rebase-libs-warning:
-rebase-libs:
-check-ant-javafx-in-fxsdk-lib:
-set-ant-javafx-in-fxsdk-lib:
-check-ant-javafx-in-fxsdk-tools:
-set-ant-javafx-in-fxsdk-tools:
-check-ant-javafx-in-platform-home-lib:
-set-ant-javafx-in-platform-home-lib:
-check-ant-javafx-in-platform-home-tools:
-set-ant-javafx-in-platform-home-tools:
-check-ant-javafx-in-probjdk-lib:
-set-ant-javafx-in-probjdk-lib:
-check-ant-javafx-in-probjdk-tools:
-set-ant-javafx-in-probjdk-tools:
-check-ant-javafx-in-macjdk-lib:
-set-ant-javafx-in-macjdk-lib:
-check-ant-javafx-in-envjdk-lib:
-set-ant-javafx-in-envjdk-lib:
-check-ant-javafx-in-envjdk-tools:
-set-ant-javafx-in-envjdk-tools:
-pre-check-ant-javafx-version:
-check-endorsed-javafx-ant-classpath:
-set-endorsed-javafx-ant-classpath:
-set-javafx-ant-classpath:
-check-ant-javafx-version:
-check-jfx-sdk-version-old:
-check-jfx-sdk-version-new:
-check-jfx-sdk-version:[echo] Detected JavaFX Ant API version 1.3
-check-jfx-deployment:
-check-dist-lib-exists:
-check-jfx-deployment-jar-current-nolib:
-check-jfx-deployment-jar-current-lib:
-check-jfx-deployment-launch:
-do-jfx-deployment-script:
-do-jfx-deployment-noscript:
jfx-deployment:
-post-jar:
-do-jar:
-pre-deploy:
-check-jlink:
-do-deploy:
-post-deploy:
deploy:
jar:
-check-concurrent-runs:
-create-temp-run-dir:
[copy] Copying 4 files to C:\Users\youse\hotelManagementProject\dist\run218081809

jfx-project-run:
[echo] Executing C:\Users\youse\hotelManagementProject\dist\run218081809\hotelManagementProject.jar using platform C:\Users\youse\Downloads\zulu8.68.0.21-ca-fx-jdk8.0.362-win_x64\zulu8.68.0.21-ca-fx-jdk8.0.362-win_x64/bin/java
[java] Exception in Application start method
[java] java.lang.reflect.InvocationTargetException
[java]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[java]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java]  at java.lang.reflect.Method.invoke(Method.java:498)
[java]  at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
[java]  at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
[java]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[java]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[java]  at java.lang.reflect.Method.invoke(Method.java:498)
[java]  at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:873)[java] Caused by: java.lang.RuntimeException: Exception in Application start method
[java]  at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)[java]  at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
[java]  at java.lang.Thread.run(Thread.java:750)[java] Caused by: javafx.fxml.LoadException:[java] file:/C:/Users/youse/hotelManagementProject/dist/run218081809/hotelManagementProject.jar!/hotelmanagementproject/FXMLDocument.fxml
[java]
[java]  at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2608)
[java]  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2550)
[java]  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2448)
[java]  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3251)
[java]  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3212)
[java]  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3185)
[java]  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3161)
[java]  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3141)
[java]  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3134)
[java]  at hotelmanagementproject.HotelManagementProject.start(HotelManagementProject.java:21)[java]    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
[java]  at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)[java]     at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
[java]  at java.security.AccessController.doPrivileged(Native Method)[java]     at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
[java]  at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)[java]   at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
[java]  at com.sun.glass.ui.win.WinApplication.lambda$null$3(WinApplication.java:178)
[java]  ... 1 more[java] Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1][java] Message: Premature end of file.[java]  at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:604)[java]     at javax.xml.stream.util.StreamReaderDelegate.next(StreamReaderDelegate.java:88)
[java]  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2520)[java]  ... 17 more
[java] Exception running application hotelmanagementproject.HotelManagementProject
[java] Java Result: 1

-remove-temp-run-dir:
[delete] Deleting directory C:\Users\youse\hotelManagementProject\dist\run218081809

jfxsa-run-no-another-jvm:

BUILD SUCCESSFUL
Total time: 2 seconds
BUILD SUCCESSFUL (total time: 3 seconds)

The main java file

package hotelmanagementproject;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;import javafx.scene.Scene;
import javafx.stage.Stage;

public class HotelManagementProject extends Application {

    @Override
    public void start(Stage stage) throws Exception {
        Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));

        Scene scene = new Scene(root);
       
        stage.setScene(scene);
        stage.show();

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {launch(args);}
}

css file

.white-bg{-fx-background-color:#fff;}
.left-form{-fx-background-color:linear-gradient(to bottom right, #686c89, #4f4c63);}
.textfield{-fx-background-color:transparent;-fx-border-color:#4f4c63;-fx-border-width:0px 0px .8px 0px;-fx-font-size:13px;-fx-font-family:"Tahoma";}
.textfield:focused{-fx-border-color:linear-gradient(to bottom right, #686c89, #4f4c63);-fx-border-width:0px 0px 1.5px 0px;}
.login-btn{-fx-background-color:linear-gradient(to bottom right, ffffff, #565d91);-fx-text-fill:#fff;-fx-font-size:13px;-fx-cursor:hand;}
.login-btn:hover{-fx-background-color:linear-gradient(to bottom right, ffffff, #2b346e);}
.close{-fx-background-color:transparent;-fx-cursor:hand;}
.close:hover{-fx-background-color:#da0404;}`

FXMLDocumentController.java file

/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/javafx/FXML2.java to edit this template
 */
package hotelmanagementproject;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;

/**
 * @author youse
 */
public class FXMLDocumentController implements Initializable {

    @FXMLprivate Label label;

    @FXMLprivate void handleButtonAction(ActionEvent event) {System.out.println("You clicked me!");label.setText("Hello World!");}

    @Overridepublic void initialize(URL url, ResourceBundle rb) {// TODO}

}

I added the font awesome to the library, as there was an error related to that previously, but then this showed up.

LinFelix
  • 1,026
  • 1
  • 13
  • 23
  • 1
    The root cause is that `XMLStreamException` caused by your call to `FXMLLoader.load()` in your `start()` method. See SO question [FXML Load exception](https://stackoverflow.com/q/22914895/2985643) which reports a similar issue. Based on that question's accepted answer you could try amending the name of your resource passed to `getClass().getResource("FXMLDocument.fxml")` in your `start()` method. If that works then your question is a duplicate of the one I linked to. Otherwise, update your question accordingly, and also specify your version of NetBeans. – skomisa Apr 12 '23 at 04:31
  • im on netbeans version 17, i tried what u said, but it didnt work, the gui works on the base case when i first create the project, after i start editing on the gui on scene builder, it doesnt work, for example i added FontAwesomeIconView, it stopped working, i added the library though to the package, but doesnt work, if i remove the edits i made, and stick with the original it works. – Yousef Khalil Apr 14 '23 at 04:45
  • *"I'm using java 8, and Javafx SDK 20"* -> Don't do that. See the release notes for the JavaFX version you are using. It will only work on Java 17+. Also, I don't use NetBenas, but my understanding is that all of the ant packaging stuff in NetBeans was written for Java 8 and will not work with modern JavaFX versions. For packaging in modern JavaFX versions see the [JavaFX tag wiki on packaging](https://stackoverflow.com/tags/javafx/info). – jewelsea Apr 14 '23 at 14:31
  • [Ikonli](https://kordamp.org/ikonli/) is a more stable choice and better maintained and documented than FontAwesome. – jewelsea Apr 14 '23 at 14:33
  • @YousefKhalil Apart from the issue of using Java 8 with JavaFX 20, your use of Java 8 on NetBeans 17 is also unsupported. So regardless of your problems with JavaFX, you must upgrade your JDK because [_"Apache **NetBeans 17 binary releases require JDK 11+**"_](https://netbeans.apache.org/download/nb17/). Upgrade Java so that it is compatible with your versions of NetBeans and JavaFX SDK, and then update your question if you still have problems. – skomisa Apr 16 '23 at 17:41
  • @jewelsea O/T: Using Ant to develop JavaFX projects on NetBeans is certainly no longer mainstream, and can be problematic if you create your project using the obvious approach (i.e. **...Java with Ant > JavaFX...**). But I found that it works for me (using NB17/JDK 19/JavaFX20) when using a modular approach to create the project: **File > New Project... > Java with Ant > Java Modular Project**. [Gluon provides a detailed and helpful tutorial](https://openjfx.io/openjfx-docs/#IDE-NetBeans) on that. (To be clear, I'm not necessarily advocating that approach, but for the record it does work.) – skomisa Apr 16 '23 at 17:54
  • @skomisa Yes, you can for dev. The question was about packaging to an exe (at least in the title). [NetBeans used to support that](https://netbeans.apache.org/kb/docs/java/native_pkg.html) and to do so relied on [NetBeans ant integration](https://docs.oracle.com/cd/E40938_01/doc.74/e40142/build_japps.htm#NBDAG2508) to use [javafx ant tasks](https://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm) that no longer exist. Sometimes there are still questions about that by people thinking it will work when it cannot. That is the information I was referring to in my earlier comment. – jewelsea Apr 16 '23 at 23:52

0 Answers0