We can create standalone jar files from the Java source code using IntelliJ. Below are the steps which can be followed for creating an uber jar.
1. For an open project, from the File
menu select, Project Structure
(Ctrl+Alt+Shift+S
).
2. Under Project Settings
, select Artifacts
.
3. By default it will be empty. Click on the +
plus icon.
4. Select JAR > From modules with dependencies...
.
5. For the module select the main module. If there is only one module it will autofill.
6. For the main class select the class with the main(String[])
function. This will prefill the defaults. Which is extract to the target JAR
and for the directory for META-INF/MANIFEST.MF
, it will be the in the src
. Click OK
.
7. Now to build the jar, go to the Build
and select Built Artifacts...
and Build
for action. This will generate the jar in the out
folder.