javacodex.com
Java Examples
Java Examples
memu home questions

What is a JAR file and how do I make it executable?

The Java Archive (JAR) file format enables you to bundle multiple files into a single archive file.

Hello World Program:

public class HelloWorld {
   public static void main(String[] args) {
      System.out.println("Hello, World");
   }
}
 

Create the JAR file:

$ jar cvf Hello.jar HelloWorld.class
added manifest
adding: HelloWorld.class(in = 426) (out= 288)(deflated 32%)

View the contents of a JAR file:

$ jar tvf Hello.jar
     0 Tue Sep 30 12:24:44 EDT 2014 META-INF/
    68 Tue Sep 30 12:24:44 EDT 2014 META-INF/MANIFEST.MF
   426 Tue Sep 30 12:24:32 EDT 2014 HelloWorld.class

Running a java program from a JAR file:

$ java -cp Hello.jar HelloWorld
Hello, World

Questions answered by this page:

Creating an Executable jar File Making Jar Files Executable How To Make an Executable Jar File




Contact: javacodex@yahoo.com