This document provides instructions for creating a JAR file in Eclipse. It describes creating a Java project with a Calculator class containing math functions, exporting the project to a JAR file which is saved to the Eclipse workspace, and how to import the JAR file into another project by adding it to the build path. The JAR can then be used to package classes for use in other Java programs. Contact details are also provided for the company Baabtra.
2. How to create a JAR file
using Eclipse
Haris NP
haris@baabtra.com
www.facebook.com/haris.np
9
twitter.com/np_haris
in.linkedin.com/in/harisnp
3. Create a Java project in Eclipse
•
The project has only class. The name of the class is Calculator.
package com.baabtra.pack;
public class Calculator {
public int func_add(int int_fn, int int_sn)
{
return int_fn+ int_sn;
}
public int func_sub(int int_fn, int int_sn)
{
return int_fn- int_sn;
}
public int func_mul(int int_fn, int int_sn)
{
return int_fn*int_sn;
}
public int func_div(int int_fn, int int_sn)
{
//assumption = No zero passed
return int_fn/int_sn;
}
}
9. • The jar file is stored to the workspace of
Eclipse
10. How to import Jar?
• In the example the package com.baabtra.pack
is imported.
11. • To add a jar
– Right click on the project properties
– Go to Java Build Path
– Click on Libraries
– Click on Add External Jars
– Select the baabtraCal jar
– Click Open
– Click OK
12.
13. • Now you can use your own classes in other
java programs.
14. Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550