1. Create a "Java Project" named as "OurOwnLibrary", and create a "Class" named "OurOwnLibrary" add three method named "diplayStaticMethod", "diplayNonStaticMethod", "diplayMethodWithArgument" under "OurOwnLibrary" class.
Here is the project Structure:
OurOwnLibrary.java
package ourownlibrary;
/**
*
* @author Aravind Sankaran Nair
*/
public class OurOwnLibrary {
/**
* @param args the command line arguments
*/
public static String diplayStaticMethod() {
// TODO code application logic here
return "You are using OurOwnLibrary Class and its diplayStaticMethod()";
}
public String diplayNonStaticMethod() {
// TODO code application logic here
return "You are using OurOwnLibrary Class and its diplayNonStaticMethod()";
}
public String diplayMethodWithArgument(String myArgument) {
// TODO code application logic here
return "You are using OurOwnLibrary Class and its diplayNonStaticMethod(). Argument is "+myArgument;
}
}
Right click "OurOwnLibrary" project and select clean and build.
A jar file is created in dist folder in which the project is located.
2. Create a "Java Project" named as "OurOwnLibraryImplimentaion", and create a "Class" named "OurOwnLibraryImplimentaion".
Here is the project Structure:
OurOwnLibraryImplimentaion.java
package ourownlibraryimplimentaion;
import ourownlibrary.OurOwnLibrary;
/**
*
* @author Aravind Sankaran Nair
*/
public class OurOwnLibraryImplimentaion {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println(OurOwnLibrary.diplayStaticMethod());
OurOwnLibrary ourOwnLibrary=new OurOwnLibrary();
System.out.println(ourOwnLibrary.diplayNonStaticMethod());
System.out.println(ourOwnLibrary.diplayMethodWithArgument("aravind"));
}
}
Right click "OurOwnLibraryImplimentaion " project and select properties.
A new window popups
Select libraries
Click Add JAR/Folder
A new window popups and ask you to add external jar file.
Specify the jar file location (ie, jar file inside dist folder of OurOwnLibrary project)
After selection the jar file, clik open
Now the jar file is listed in the librarylist
Click ok.
Run OurOwnLibraryImplimentaion.java
Output:
You are using OurOwnLibrary Class and its diplayStaticMethod()
You are using OurOwnLibrary Class and its diplayNonStaticMethod()
You are using OurOwnLibrary Class and its diplayNonStaticMethod(). Argument is aravind
Here is the project Structure:
OurOwnLibrary.java
package ourownlibrary;
/**
*
* @author Aravind Sankaran Nair
*/
public class OurOwnLibrary {
/**
* @param args the command line arguments
*/
public static String diplayStaticMethod() {
// TODO code application logic here
return "You are using OurOwnLibrary Class and its diplayStaticMethod()";
}
public String diplayNonStaticMethod() {
// TODO code application logic here
return "You are using OurOwnLibrary Class and its diplayNonStaticMethod()";
}
public String diplayMethodWithArgument(String myArgument) {
// TODO code application logic here
return "You are using OurOwnLibrary Class and its diplayNonStaticMethod(). Argument is "+myArgument;
}
}
Right click "OurOwnLibrary" project and select clean and build.
A jar file is created in dist folder in which the project is located.
2. Create a "Java Project" named as "OurOwnLibraryImplimentaion", and create a "Class" named "OurOwnLibraryImplimentaion".
Here is the project Structure:
OurOwnLibraryImplimentaion.java
package ourownlibraryimplimentaion;
import ourownlibrary.OurOwnLibrary;
/**
*
* @author Aravind Sankaran Nair
*/
public class OurOwnLibraryImplimentaion {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println(OurOwnLibrary.diplayStaticMethod());
OurOwnLibrary ourOwnLibrary=new OurOwnLibrary();
System.out.println(ourOwnLibrary.diplayNonStaticMethod());
System.out.println(ourOwnLibrary.diplayMethodWithArgument("aravind"));
}
}
Right click "OurOwnLibraryImplimentaion " project and select properties.
A new window popups
Select libraries
Click Add JAR/Folder
A new window popups and ask you to add external jar file.
Specify the jar file location (ie, jar file inside dist folder of OurOwnLibrary project)
After selection the jar file, clik open
Now the jar file is listed in the librarylist
Click ok.
Run OurOwnLibraryImplimentaion.java
Output:
You are using OurOwnLibrary Class and its diplayStaticMethod()
You are using OurOwnLibrary Class and its diplayNonStaticMethod()
You are using OurOwnLibrary Class and its diplayNonStaticMethod(). Argument is aravind