Maven Hello World..

with MANIFEST.MF.

Directory Layout

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>biz.tugay</groupId>
    <artifactId>maven-hello</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <archive>
                        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
</project>

MavenHello.java
package biz.tugay;
 
class MavenHello {
 
    public static void main(String... args) {
        System.out.println("Maven Hello!");
    }
}

MANIFEST.MF
Main-Class: biz.tugay.MavenHello
 

In Action
Korays-MacBook-Pro:maven-hello-world koraytugay$ mvn install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building maven-hello 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-hello ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-hello ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/koraytugay/Desktop/maven-hello-world/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-hello ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/koraytugay/Desktop/maven-hello-world/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-hello ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-hello ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ maven-hello ---
[INFO] Building jar: /Users/koraytugay/Desktop/maven-hello-world/target/maven-hello-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ maven-hello ---
[INFO] Installing /Users/koraytugay/Desktop/maven-hello-world/target/maven-hello-1.0-SNAPSHOT.jar to /Users/koraytugay/.m2/repository/biz/tugay/maven-hello/1.0-SNAPSHOT/maven-hello-1.0-SNAPSHOT.jar
[INFO] Installing /Users/koraytugay/Desktop/maven-hello-world/pom.xml to /Users/koraytugay/.m2/repository/biz/tugay/maven-hello/1.0-SNAPSHOT/maven-hello-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.317 s
[INFO] Finished at: 2017-02-10T11:44:15+02:00
[INFO] Final Memory: 15M/310M
[INFO] ------------------------------------------------------------------------
Korays-MacBook-Pro:maven-hello-world koraytugay$ cd target/
Korays-MacBook-Pro:target koraytugay$ java -jar maven-hello-1.0-SNAPSHOT.jar 
Maven Hello!