Search code examples
javadeploymentexportjavafx-11

How to export JavaFX gradle project as a standalone executable file for deployment?


I have completed my JavaFX application within gradle build system, and it is working fine in all way. Now I want to export as a .EXE file for standalone software distribution, I tried much more tricks but no gain. If some one can help me out to wrap my project in a software setup, It would be grateful.


Solution

  • Follow these steps to export your JavaFX project into executable Jar

    1. Goto> Project Structure
    2. Goto>>Artifacts
    3. Click "+">> To add new artifact
    4. It will shows a dropdownlist
    5. Select>>Jar>>From module with dependencies
    6. You will see a nested window as shownpic2
    7. Select Main class of your project
    8. Check In the Option " Copy to output directory.." >>Ok
    9. Goto>> Menu-bar>>Build>>Build Artifacts
    10. Select>> your Project.jar>> Build
    11. This will create executable jar file in your project source folder
    12. Locate your jar file in path project\out\artifacts..
    13. Now you can run this jar file simple cmd commad or with batch file
      • Cmd Command>> Java -jar project.jar
    14. Using batch file>> make .bat file name it "RUN" and write these commands inside Pic1

    15. Specify the Java Runtime path and "Javafx Sdk path" along with VM options & Project Jar

    16. Run your standalone application .. Enjoy ;)