Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 4 Writing Java Applications, Java Development Tools.
Advertisements

Using Eclipse. Getting Started There are three ways to create a Java project: 1:Select File > New > Project, 2 Select the arrow of the button in the upper.
1 eclipse Tips. 2 What is eclipse? Eclipse is a popular IDE (Integrated Development Environment) that we will use to create, compile, execute, and test.
Java Integrated Development Environments: ECLIPSE Part1 Installation.
16-Jun-15 javadoc. 2 Javadoc placement javadoc comments begin with /** and end with */ In a javadoc comment, a * at the beginning of the line is not part.
Object-Oriented Enterprise Application Development Javadoc Last Updated: 06/30/2001.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
JavaDoc COMP 302. JavaDoc javadoc: The program to generate java code documentation. Input: Java source files (.java)  Individual source files  Root.
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMING PRACTICES API documentation.
1 CSE 331 Java Packages; JAR Archives slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia
PACKAGES Mimi OpkinsCECS277. What We’ll Cover  Packages and Import Statements  The Package java.lang  Package Names and Directories  The Default Package.
1 eclipse Tips. 2 What is eclipse? Eclipse is a popular IDE (Integrated Development Environment) that we will use to create, compile, execute, and test.
Javadoc. The Plan ● What is Javadoc? ● Writing Javadoc comments ● Using the Javadoc tool ● Demo ● Practice.
CSC172 Intro Pepper. Goals Reminder of what a class is How to create and use classes How to design classes How to think in terms of objects How to comment.
JavaDoc1 JavaDoc DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY July 24, 2006 by Emil Vassev & Joey Paquet revision 1.2 –
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.
Plug-in Development Environment. Session Outline Tools Installation Configuration New Project Basic Debugging Remote Debugging.
Program documentation using the Javadoc tool 1 Program documentation Using the Javadoc tool.
CPSC1301 Computer Science 1 Overview of Dr. Java.
Winter 2006CISC121 - Prof. McLeod1 Last Time Misc. useful classes in Java: –String –StringTokenizer –Math –System.
LEARNING HTML PowerPoint #1 Cyrus Saadat, Webmaster.
Javadoc Comments.  Java API has a documentation tool called javadoc  The javadoc tool is used on the source code embedded with javadoc-style comments.
Software Documentation Section 5.5 ALBING’s Section JIA’s Appendix B JIA’s.
10-Nov-15 Java Object Oriented Programming What is it?
Documentation javadoc. Documentation not a programmer's first love lives in a separate file somewhere usually a deliverable on the schedule often not.
1 JAVA API & Packages Starring: Java Documentation Co-Starring: BlueJ IDE.
Fall 2015CISC124 - Prof. McLeod1 CISC124 Have you filled out the lab section survey? (As of last night 54 left to fill out the survey.) TA names have been.
Class Libraries Chapter 1 1 Source Intro to Java Programming Y. Daniel Liang.
Javadoc Dwight Deugo Nesa Matic
JavaDoc and Contracts Spring Documenting Contracts with JavaDoc Contract model for methods Preconditions Postconditions JavaDoc Industry standard.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Javadoc. Purpose of javadoc javadoc is a program that reads your Java program and produces great-looking documentation in HTML format Without any help,
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
CreatingClasses-SlideShow-part41 Creating Classes part 4 Barb Ericson Georgia Institute of Technology Dec 2009.
A brief introduction to javadoc and doxygen. What’s in a program file? 1. Comments 2. Code.
Building Packages BCIS 3680 Enterprise Programming.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
Aside: Running Supplied *.java Programs Just double clicking on a *.java file may not be too useful! 1.In Eclipse, create a project for this program or.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
Winter 2006CISC121 - Prof. McLeod1 Stuff We had better discuss a midterm date… –27 Feb. to 3 March or –6 to 10 March.
Today protected access modifier Using the debugger in Eclipse JUnit testing TDD Winter 2016CMPE212 - Prof. McLeod1.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Today Encapsulation. Build a fully encapsulated Halloween class, going from Halloween1 to Halloween6 (eventually!): –The final version will have overloaded.
Java IDE Dwight Deugo Nesa Matic
Advanced Programing practices
More Sophisticated Behavior
CMPE212 – Stuff… Assn 2 due next Friday. Winter 2018
CMPE212 – Stuff… Exercises 4, 5 and 6 are all fair game now.
Introduction to javadoc
Fall 2018 CISC124 12/1/2018 CISC124 Note that the next assignment, on encapsulation, is due next Wednesday at 7pm – not Friday. The next Quiz is not until.
Java External Libraries & Case Study
CISC124 Assignment 3 due tomorrow at 7pm.
CISC124 Assignment 4 on Inheritance due next Friday.
JavaDoc and Contracts Fall 2008.
Fall 2018 CISC124 2/1/2019 CISC124 Note that the next assignment, on encapsulation, is due next Wednesday at 7pm – not Friday. The next Quiz is not until.
Applying OO Concepts Using Java
Advanced Programing practices
Fall 2018 CISC124 2/24/2019 CISC124 Quiz 1 marking is complete. Quiz average was about 40/60 or 67%. TAs are still grading assn 1. Assn 2 due this Friday,
Introduction to javadoc
CMPE212 – Reminders Assignment 2 sample solution is posted.
CMPE212 – Reminders Assignment 2 due this Friday.
CMPE212 – Reminders Quiz 1 marking done. Assignment 2 due next Friday.
CMPE212 – Reminders Assignment 2 due in a week.
Classes 5/5 May 14, 2019 ICS102: Classes 5/5.
Working with Libraries
CMPE212 – Reminders Assignment 2 due today, 7pm.
Winter 2019 CMPE212 5/25/2019 CMPE212 – Reminders
Presentation transcript:

Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing Winter 2016CMPE212 - Prof. McLeod1

Winter 2016CMPE212 - Prof. McLeod2 Javadoc Javadoc.exe is a program that comes with the JDK. (It is in the same directory as javac.exe and java.exe – the “bin” folder). It is not included in the JRE only. If I have written a class, “ MyClass.java ”, that contains properly formatted comments (more below), then running “ javadoc MyClass.java ” generates a file “ MyClass.html ”. The html file contains external documentation generated from the formatted comments in the source code.

Winter 2016CMPE212 - Prof. McLeod3 Javadoc - Cont. Normal block comments in Java are delimited by “ /* ” and “ */ ”. Everything between these delimiters, usually multiple lines, is a comment. Javadoc block comments are delimited by “ /** ” and “ */ ”.

Winter 2016CMPE212 - Prof. McLeod4 Javadoc - Cont. The general form of a Javadoc comment: /** * Summary sentence. * More general information about the * class, attribute or method which * follows the comment, using as many lines * as necessary. (html tags can be included) * * javadoc tags to specify more specific * information, such as parameters and * return values for a method */

Winter 2016CMPE212 - Prof. McLeod5 Javadoc - Cont. The general form of a Javadoc tag comment The tags you use depend on what you are describing (class, method or attribute). In the case of methods, you can have a tag for each parameter, the return value, and a tag for each thrown exception. Eclipse (really nice!!) will generate a blank tag for you after you type “ /** ”. Typically, you will only write javadoc comments for public attributes and methods…

Winter 2016CMPE212 - Prof. McLeod6 Eclipse Javadoc Assist For example, if you have the method header: public static double[] generateRandomArray(int size) Type /** right above this line and press. You will get: /** * size */ public static double[] generateRandomArray(int size)

Winter 2016CMPE212 - Prof. McLeod7 Eclipse Javadoc Assist, Cont. Then you have to finish the comment: /** * Generates an array of random doubles. * * The method uses the Math.random() method to generate * an array of doubles between 0.0 and 1.0. size The desired size of the array. The array of random doubles. */

Winter 2016CMPE212 - Prof. McLeod8 Eclipse Javadoc Assist, Cont. Hold your cursor over the method header and you will get a preview of what the processed Javadoc will look like: (Or view the Javadoc in the same view as the Console tag.)

Winter 2016CMPE212 - Prof. McLeod9 Common Javadoc @seepackageName.ClassName,

Winter 2016CMPE212 - Prof. McLeod10 Javadoc - Cont. Html tags can also be added to the comments to add more formatting to the resulting document: – for emphasis – for code font – for images – for bulleted lists –Etc…

Winter 2016CMPE212 - Prof. McLeod11 Javadoc Reference The best reference for javadoc is at: mentation/index-jsp html

Winter 2016CMPE212 - Prof. McLeod12 Javadoc - Cont. The output from Javadoc looks exactly like the API documentation you have already seen - since that is the way it has been generated! The advantage is that when source code is changed, the Javadoc comments can be changed in the source, at the same time. The external documentation is then easily re-generated. Javadoc also provides a consistent look and feel to these API documents.

Winter 2016CMPE212 - Prof. McLeod13 Javadoc - Cont. Most modern IDE’s (like NetBeans and Eclipse) allow you to run Javadoc from within the environment, and provide tools and wizards to help you create comments. In Eclipse, select “Project”, then “Generate Javadoc…”. Let’s run javadoc on the Halloween6 class. (Note that the first time you do this, you will have to tell Eclipse where javadoc.exe resides.)

Winter 2016CMPE212 - Prof. McLeod14 Packages “ package ” is a Java keyword. It provides a means of grouping classes together into a package. All classes in a package share some common theme. It is used as in: package package_name; This line is at the top of a class definition, before the public class…

Winter 2016CMPE212 - Prof. McLeod15 Packages and Eclipse Eclipse would prefer that you to create classes in a package. When you create a new Class, specify what package you want it to belong to. This will automatically add the package package_name; line to the top of the class, the proper folder is created in src, and the new class in saved in this folder. Eventually, you will create a *.jar (or *.zip) file with all the *.class files in your package. Put this user library somewhere in or below your classpath and then another class will be able to import it.

Winter 2016CMPE212 - Prof. McLeod16 Packages, Cont. The structure is: classpath\folder\packagename “folder” can be a series of folders. The import statement looks like: import folder.packagename.*; The “.* ” says to import all classes in the package, or you can import specific classes.

Winter 2016CMPE212 - Prof. McLeod17 Packages and Eclipse, Cont. You can add to the classpath by right clicking on Project - Properties to get the following window: Then choose “Add…”

Winter 2016CMPE212 - Prof. McLeod18 Packages, Cont. We have been importing existing packages already import java.util.Scanner; import java.io.*; …

Winter 2016CMPE212 - Prof. McLeod19 Packages, Cont. Note that Java automatically imports the java.lang.* package for you. This package contains many classes fundamental to the Java language: –String –Math –all Wrapper classes ( Boolean, Character, Integer, Long, Float, and Double ) –System, –and a few others…

Winter 2016CMPE212 - Prof. McLeod20 static Import Used to import some or all of the static members in a class, so that they can be used as if they were declared within the class that uses them. Example: import static java.lang.Math.*; Imports all methods and attributes in the Math class. See StaticImportMath.java.

Winter 2016CMPE212 - Prof. McLeod21 Aside – Viewing Java Source Code To do this you must have the file src.zip available. If you did not get it with the JDK you downloaded, you can download it separately and then put it in the root JDK folder, for example. The first time you try this in Eclipse you can click on a button that will allow you to specify the location of src.zip. Open the Libraries tree that is always part of your project to find the classes listed in the package of interest.

Viewing Java Source Code The first time you try this you will see: Click on “Attach Source…” Winter 2016CMPE212 - Prof. McLeod22

Viewing Java Source Code, Cont. Choose “External location” and click on “External File…” Winter 2016CMPE212 - Prof. McLeod23

Viewing Java Source Code, Cont. Go to the folder of your newest jdk and choose “src.zip”, then “Open”, then “OK”. Winter 2016CMPE212 - Prof. McLeod24

Viewing Java Source Code, Cont. Now you can view the source code files for any class in the API! (Can’t edit them, however…) Winter 2016CMPE212 - Prof. McLeod25

Aside – Protected Access So far we have used public and private access modifiers. protected is what you get if you don’t specify an access modifier. This means “ public inside the package, private outside the package”. Used in the API. Use sparingly! Winter 2016CMPE212 - Prof. McLeod26