Creating a Stand-alone Jar File in IntelliJ

Navigate IntelliJ
File, "Project Structure", Artifacts
Click + "Plus Sign", and Select "Jar", "From modules with dependencies"
Now select the "Main Class" you wish to use (e.g. "DemoClass")

Keep defaults as-is
"extract to the target JAR"
"Directory to META-INF/MANIFEST.MF" points to source folder
Click "OK"

Now build the jar file
Build, "Build Artifacts", "Build"

Your jar file should now be in, or the equivalent
JavaFun/out/artifacts/JavaFun_jar

Run the file with
java -jar JavaFun.jar

Leave a Reply