How to create a jar of java programs ?
How to execute a jar ?
How to extracting a jar ?
1) Create a java program as per given below java code.
2) Compile this code as (javac CreateJar.java).
3) Run this code as (java CreateJar).
After this you have got two class files (1) AddData.class and (2) CreateJar.class.
4) Create A Menifest.txt file, In this file write Main class name.
Main-Class: CreateJar
5) Create A folder as createJar name, Then past all three files.
AddData.class, CreateJar.class, Menifest.txt
After complete these process, open Command prmpt and type
jar -cfmv CreateJar.jar Menifest.txt *
Commands for jar:-
For Creating Jar:
jar -cfmv CreateJar.jar Menifest.txt *
For Xtracting Jar:
jar -xfv CreateJar.jar
For executing Jar:
java -jar CreateJar.jar
/*compile this java code and create your own jar */How to execute a jar ?
How to extracting a jar ?
1) Create a java program as per given below java code.
2) Compile this code as (javac CreateJar.java).
3) Run this code as (java CreateJar).
After this you have got two class files (1) AddData.class and (2) CreateJar.class.
4) Create A Menifest.txt file, In this file write Main class name.
Main-Class: CreateJar
5) Create A folder as createJar name, Then past all three files.
AddData.class, CreateJar.class, Menifest.txt
After complete these process, open Command prmpt and type
jar -cfmv CreateJar.jar Menifest.txt *
Commands for jar:-
For Creating Jar:
jar -cfmv CreateJar.jar Menifest.txt *
For Xtracting Jar:
jar -xfv CreateJar.jar
For executing Jar:
java -jar CreateJar.jar
import java.util.Scanner;
class CreateJar {
public static void main(String args[]){
Scanner scan = new Scanner(System.in);
System.out.println("enter value 1 :");
int a = scan.nextInt();
System.out.println("enter value 2 :");
int b = scan.nextInt();
AddData ad = new AddData(a,b);
ad.adddata();
}
}
class AddData{
int a,b;
public AddData(int a, int b){
setA(a);
setB(b);
}
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
public int getB() {
return b;
}
public void setB(int b) {
this.b = b;
}
public void adddata(){
int c = getA()+getB();
System.out.println("Addition is : "+c);
}
}
No comments:
Post a Comment