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 :
- Recent Java releases do not provide a separate JRE that you install on the system anymore like you used to do.
- 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
- 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)
- 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:
- 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.
- 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.
- JDK 14+ can use jpackage to create a native launcher or installer. Note: you need JavaFX Jmod files.
- 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).