The following example shows creating an executable JAR file in Java.
First create a simple standalone java application, for instance a simple Swing UI application.
Create a manifest file manifest.txt with Main-Class attribute.
Ensure to enter a new line at the end of manifest file.
Otherwise some systems may throw failed to load Main-Class error.
Main-Class: com.btc.ExeJARApplication
Create an executable JAR using jar command from the console (Ensure to include JDK_HOME\bin in Path environment variable).
jar cvfm [jar-file] [manifest-file] [dirs/files]
jar cvfm test.jar manifest.txt com
Run the executable JAR from the console or from "Open with" windows dialog.