I am using Intellij IDEA 12.1.3 on MAC OS X 10.8.3 to create an executable jar file.
I go to File -> Project Structure -> Artifacts -> + -> Jar -> From modules with dependencies -> Selected Main Class after browsing -> selected extract to the target jar -> Directory for META-INF automatically gets populated -> OK -> Apply -> OK -> Build -> Build Artifacts -> Build
Now If I try to run jar using:
java -jar path_to_jar/jar_file
I get this error
no main manifest attribute, in path_to_jar/jar_file
I check the MANIFEST.MF file in the jar file it indeed does not have Main-Class entry.
Using Maven by adding the <build> section to pom.xml sucesfully creates working jar.
> mvn assembly:assembly