I am creating a project on JavaFX and using Gradle (I use IntelliJ IDEA). The project is ready and runs more or less like I'd like it to. Now as I tried to make it a executable for more convinient use I found instructions that said I first need an executable JAR file. Making JAR file I get Zip archive file instead. In IntelliJ it shows that I have JAR file but if I open it in explorer it has only ZIP file and if I try to run my JAR on cmd it says there is no .jar files. Created JAR in IntelliJ ZIP arcihive file in explorer
Chat GPD suggested that there is a problem in Build.Gradle file but if I changed it as it told me to nothing changed.
Please check First:
.jar.jarfiles with a JRE and not with your zip app.Solution for a modular app:
If you have a modular app, you must create a native package (exe, msi,...) with jpackage or jlink. You won't get happy without that. If you create the JavaFX application with IntelliJ, there is already a Gradle task defined for doing exactly this.
Solution for a non-modular app:
First, your main class mustn't extend from another class. This will not work.
Second, you must create a fat JAR which contains all needed dependencies.
Here is an example of a working build.gradle file including a task which can perfectly build the executable JAR:
If you can't get it to work, you can download a preconfigured and full working template project from my GitHub and edit it to your needs:
https://github.com/davidweber411/javafx-JavaFxAppGradleNonModular
If it helped you, I would appreciate a star!
Additional information:
Note, that you need to have an according JDK installed.