Create jar file in java using command prompt

When we do programming with java, there is several way to create our program in executable file. Some Java IDE (Integrated Development Environment) have menu for create jar file.

If you can not use your IDE for create JAR file for source code. you can use command prompt for do that task. ALl windows Operation System has this command prompt.

To open the command prompt file, you can click Start–>Run. In text-box type cmd like figure below:

run cmd
Run Panel CMD for Create jar file

Press OK to enter command prompt. The command prompt form will show soon. Command prompt can you see as below figure.

Command Prompt for create jar file in java
Command Prompt for create jar file in java

We will use this command prompt to create jar file. there is some step for creating JAR file

Navigate command prompt path to your java files or classes

C:\>cd \your folder

Set Path to get JDK in folder BIN, this path base on your installation file

C:\your folder> path c:\Program Files\Java\jdk1.5.0_09\bin;%path%

jdk1.5.0_09 is base on type of java version

Compile your java file to generate class file

C:\your folder> javac *.java

Create a manifest file

C:\your folder> echo Main-Class: Apotik>manifest.txt

Create JAR file

C:\your folder> jar cvfm Apotik.jar manifest.txt *.class

Run executable file (JAR file)

C:\your folder> Apotik.jar

For successes this step you must make sure that you have install JDK in your local. Creating JAR file will not complete if your local do not have JDK yet.

Leave a Reply