User:Podbrushkin/Java: Maven Jar Executable

This is a step-by-step instruction on how to create executable jar archive with Maven.

For more straightforward experience this instruction relies on command-line ability to create folders, files and changing content of files: If you want to use, install Powershell Core by executing  , and check if it's available:. Preinstalled Powershell 5 will not suite you as it brings some encoding-related problems, which can result in not compilable source files.
 * - creates nested directories;
 * - creates a file and a path if needed;
 * or
 * - writes text from clipboard to file. Can't create directories. Use double  to append instead of override.

Overall, you wouldn't need Explorer, IDE or any text editors to follow this tutorial.

Creating executable jar

 * Create a new folder with the name of your choice,  for example, and open CMD in it.
 * To open current folder in CMD, type  in address bar and press Enter.


 * Create a new file :‎
 * Use  to fill file with text from clipboard.
 * Line 11 is optional, it helps to avoid Maven warnings and possible charset problems;
 * Lines 14-30 are needed to make jar archive executable;


 * Create directory structure:
 * Everything after  is java package structure, which should match line 24 in pom.xml and first line in.
 * Everything after  is java package structure, which should match line 24 in pom.xml and first line in.


 * Create a new file
 * Use  to fill file with text from clipboard.


 * From MyFolder, execute, it will create an archive in   directory.


 * Run application:

Hello world, ?? ??????? ??? ??? ????, Буря мглою небо кроет... ? Some unicode characters were replaced with question marks, but that's another story.
 * You will see output:

Project's file structure: MyFolder\pom.xml MyFolder\src\main\java\example\SmallApp.java