Wednesday, October 29, 2014

Making Executable Jar File


Creating an executable JAR file. Here is the general procedure for creating an executable JAR:

1. Compile your java code (for ex: Hello.java), generating all of the program's class files.

2. Create a manifest file containing the following 2 lines: (named as Hello.mf)
Manifest-Version: 1.0
Main-Class: Hello  (name of the main class)

Note: The name of the file should end with the .mf suffix. It is important that the file ends with a blank line.

3. To create the JAR, open command prompt and type the following command:
jar cmf manifest-file jar-file input-files
Ex: jar cmf Hello.mf Hello.jar *.java *.class

Note: The input-files must include any class files, images, sounds, etc. that your program uses. Optionally, you can include the program's .java files in the JAR. See below for adding directories to  the JAR.

4. To view the contents of the JAR, type:
jar tf jar-file
Ex: jar tf Hello.jar

5. Execute the application from the command line by typing:
java -jar jar-file

Ex: java -jar Hello.jar

1 comment:

  1. Super. There should be references to Java documentation or tutorials.

    ReplyDelete

Understanding Essential DNS Record Types for Web Administrators

  Understanding Essential DNS Record Types for Web Administrators Introduction The Domain Name System (DNS) acts as the backbone of the inte...