HOW TO CREATE JAR FILE IN JAVA

A JAR (Java ARchive) is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file for distribution. JAR files are archive files that include a Java-specific manifest file. They are built on the ZIP format and typically have a .jar file extension.

Steps to execute this Java Program in Eclipse.
  1. Create a new Java Project and create a new Package.
  2. Write the JarFile.java in eclipse.
  3. Then export the JarFile.java by right click on program and click EXPORT.
  4. In Java Click on Jar File.
  5. Give the file name and store path for jar file.
  6. Click finish.
  7. Write the Next Java Program (eg. Assignment8.java).
  8. Execute the program.
JarFile.java
package SMD8;

public class JarFile {

 public static void main(String[] args){
  
  int i=10, j=20;
  
  Assignment8 A = new Assignment8();
  
  System.out.println("This out is from JarFileSMD8.jar");
  
  System.out.println(A.wc());
  
  System.out.println("Addition: "+(i+j));  
  
 }
 
}
Assignment8.java
package SMD8;

public class Assignment8 {

 public String wc(){
  return "BE - IT 2017 - 18000";
 }
 
}
This Video might be Helpful.

Comments