#5, First Floor, 4th Street , Dr. Subbarayan Nagar, Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to create executable jar file from the class files?

Description

Executable jar file can be created for the set of class files. Following steps demonstrates the creation of Sorting.jar file for the class file Sorting.class.

Sample Code
  • Filename: Sorting.java

import java.util.*;
class Sorting {
public static void main(String args[]) {
//Sorting Integer in natural order
int n[] = {40,20,29,65,74};
Arrays.sort(n);
System.out.println("Sorted list of Integer");
for(int i:n) {
System.out.println(i);
}
//Sorting String in natural order
String s[] = {"dog","cat","animal","bird","dove"};
Arrays.sort(s);
System.out.println("Sorted list of String");
for(String i:s) {
System.out.println(i);
}

}
}

  • Commands to be executed

To create jar file:

jar – cvfe Sorting.jar Sorting Sorting.class

To execute jar file:

java -jar Sorting.jar


Screenshots