top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to create Executable Jar Archive (JAR) File in JAVA?

+2 votes
509 views
How to create Executable Jar Archive (JAR) File in JAVA?
posted Dec 22, 2014 by Dominic

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Let us say, we have 2 compiled classes Employee and Person inside the folder "ALL" which resides inside the folder "Java". Employee class contains static void main method.

Before creating a Jar file, first create a mainclass file in the Java folder. Specify the name of the class in which main methods resides. Here (“Main-Class: All.Employee”) and press enter.

Open command prompt and navigate to Java Folder. Enter the following command in the command prompt “jar cmf mainclass myfirst.jar All/*.class” and press enter. Executable jar will created. To test the newly created jar, use following command “java -jar myfirst.jar”

answer Dec 24, 2014 by Karthick.c
Similar Questions
+3 votes

I want to write a Makefile that compiles. My question here is how to add an external library using Make syntax?

0 votes

I run my code in Eclipse IDE and its fine. I have export it as jar file from Eclipse and run on terminal as jar file, it generates Error: java.lang.NullPointerException. Could not understand why is it so.

+1 vote

How to create frameworks in java and how can I use framework in .class file for my project?

...