Create runnable jar from intellij
1. Configure a runnable JAR artifact
File → Project Structure… (or Ctrl+Alt+Shift+S on Windows/Linux).
Go to Artifacts (left side).
Click the + button → JAR → From modules with dependencies….
Module: select your module (e.g. SimpleJarDemo).
Main Class: click the ... button, choose your Main class.
Option Include in project build can stay checked if you want.
IntelliJ will create an artifact like:
Output directory: something like out/artifacts/SimpleJarDemo_jar.
By default it will use the “extract to the target JAR” layout, which is fine for a simple app (your compiled classes + any dependencies inside one JAR).
Go to the main menu: Build → Build Artifacts….
In the popup, select your artifact (e.g. SimpleJarDemo:jar) → choose Build.
IntelliJ will compile and create the JAR in the artifact output directory, e.g.:<project-root>\out\artifacts\SimpleJarDemo_jar\SimpleJarDemo.jar
(You can see the exact path at the top of the Artifacts configuration page.)
3. Run the JAR from the command line
Open a terminal (Command Prompt, PowerShell, or shell):
bashCopy codecd <project-root>\out\artifacts\SimpleJarDemo_jar java -jar SimpleJarDemo.jar