1 Reply Latest reply on Feb 17, 2020 12:54 AM by bouye-JavaNet

    Exporting an executeable jar

    f06e1d87-dcda-4191-abe4-64a515f18c0b

      Hi,

      does anyone knows how to export an executeable jar in eclipse or IntelliJ since JavaFX is open source?

       

      Kindly regards

      Daniel

        • 1. Re: Exporting an executeable jar
          bouye-JavaNet

          In Intellij you can create a JAR file by adding an artifact (module settings -> artifact -> +) on your project which may or may not include the libraries that your are using. You can either set the JAR to build automatically when you compile your program or you can do it manually by going to Build menu -> Build artifact.

           

          An executable JAR on the other hand is not something you do anymore nowadays anyway :

          1. Recent Java releases do not provide a separate JRE that you install on the system anymore like you used to do.
          2. As JavaFX is separate from the JDK, you would still need to specify --module-path and --add-modules for the JavaFX application to run so you cannot do this by simply double-clicking on the JAR
          3. It was never a good solution anyway as a lot of archive (ZIP) manager tools were replacing default app for JAR file handling on Windows (you would end up opening the JAR in your ZIP utility instead of running the app)
          4. You should provide a native launcher with embedded JVM instead. Using the JDK tools, the app usually rely the JAR file(s) you've produced in your IDE and have a parameter file that sets arguments from the command line:
            1. JDK 8, 9 and 10 can use javapackager to create a native launcher or installer. Note : use Oracle JDK that come with the tool and JavaFX inside. OpenJDK do not have both.
            2. JDK 11, 12, and 13 can use jlink instead. Note: this creates a launch script (not really a native launcher). You need JavaFX Jmod files.
            3. JDK 14+ can use jpackage to create a native launcher or installer. Note: you need JavaFX Jmod files.
            4. Another alternate option is GraalVM that creates a native app (not a native launcher that relies on the embedded JVM + JAR file). Note : this solution has some technical limitations due to how native compiling is working when statically compiling the program (dynamic invocation and reflection may not be supported).