q-8:-how to create the jar file in java
ans:
1) Jar stands for java archive file
2)Jar file contains collection of packages.
3)Packages contains collection of classes.
4)All predefined classes .class files are coming in the form of rt.jar file
5)Location of rt.jar file
C:\Program Files\Java\jdk1.7.0_79\jre\lib \rt.jar
The following way to create the jar file
1)First create the hello.java file in C:\abc folder
package com.hellos;
public class hello
{
{
System.out.println("Hello classs");
}
}
compile the program
2)create the maniss.java file in D:\java
package com.mainss.main;
import com.hellos.hello;
class maniss
{
public static void main(String[] args)
{
hello h=new hello();
h.hellos();
}
}
2) Create the jar file using jar command in C:\abc \myfile.jar
3)to compile and execute mainss class first we can set the class path enviornment variable to myfile.jar
compile the mainss.java file
run the mainss.java file:-