G 54 PRG Programming Lecture 26 Java External










- Slides: 10

G 54 PRG Programming Lecture 26 Java External Libraries & Case Study Amadeo Ascó Adam Moore 1

Previously • GUI Example – Switch project Amadeo Ascó , Adam Moore 2

Overview • Java External Libraries & Case Study – What is a library? • Internal • External – Required – Add External Libraries to Eclipse – Case Study Amadeo Ascó , Adam Moore 3

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 Amadeo Ascó , Adam Moore 4

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. Super. CSV • Public method and classes are accessible by all • Protected methods are accessible by inheritance (extends) and by the same package member classes Amadeo Ascó , Adam Moore 5

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 Amadeo Ascó , Adam Moore 6

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 Amadeo Ascó , Adam Moore 7

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) • • Amadeo Ascó , Adam Moore 8

Add External Libraries to Eclipse • Add link to documentation • Press “OK” button in the “Preferences” window Amadeo Ascó , Adam Moore 9

References • Super CSV Java library to read and write Comma Separated Values (CSV) files http: //supercsv. sourceforge. net/ • JFree. Chart Java library to display charts http: //www. jfree. org/jfreechart/ Amadeo Ascó , Adam Moore 10