Java External Libraries & Case Study 26 Java External Libraries & Case Study
Previously GUI Example Switch project
Overview Java External Libraries & Case Study What is a library? Internal External Required Add External Libraries to Eclipse Case Study
What is a library? A library is composed of reusable code Saves time by Providing code that performs a programming task The code does not need to be designed and programmed again Reducing validation of the code The code does what it is supposed to Reducing required tests Providing efficient operations
What is a library? Internal libraries are those provided as part of the language, e.g. java. and jaxax.swing packages External libraries are those that have to be included in the language and at run time, e.g. SuperCSV Public method and classes are accessible by all Protected methods are accessible by inheritance (extends) and by the same package member classes Protected methods are also accessible by package member classes
Required Required the .jar(s) files with the compiled code A library must provide documentation, e.g. javadoc Some time source files are also provided, normally for open source libraries
Add External Libraries to Eclipse Download the library into your computer Install the library, follow the library installation gudes Open Eclipse Select menu option “Window” Select “Preferences” from dropdown menu Open the “Java” option from the left hand side tree
Add External Libraries to Eclipse Open the “Build Path” option Select User library Press “New” button (top right hand side) Give a name to the library, use the library own name Select the new library entry Press “Add Jars...” button Select the jar file(s)
Add External Libraries to Eclipse Add link to documentation Press “OK” button in the “Preferences” window
References Super CSV JFreeChart Java library to read and write Comma Separated Values (CSV) files http://supercsv.sourceforge.net/ JFreeChart Java library to display charts http://www.jfree.org/jfreechart/