03. Compiling a Javadoc

Compiling is as easy as a single comment. As an example, we'll compile the bottom code object Car. We can do this easily with the javadoc command.

$ javadoc -d CarHTML Car.java

Javadoc Options

Here are some options you may find helpful.

-author
Includes an author section.
-classpath [path]
Specifies where to search for a references .class file.
-d [path]
Specifies where to generate the document.
-version
Generated documentation includes a version section.
-private
Generated documentation includes private fields and methods.
/**
 * A Car object contains the parameters and functionalities of
 * a basic automobile. 
 *
 * @author CodeSnipcademy
 * @version 4.0.0 Dec 26, 2014.
 */
public class Car {
 
   /**
    * The number of wheels on any car.
    */ 
    public static final int numWheels = 4;
 
    private String make;
    private String model;
    private String color;
    private int yearBuilt;
    private int currentSpeed;
 
   /** 
    * Default constructor for car.
    *
    * Sets to most generic car model.
    *
    */
    Car () {
        this.make = "Toyota";
        this.model = "Camry";
        this.color = "silver";
        this.yearBuilt = 2000;
    }
 
   /** 
    * Constructor that makes a Car object according to specifics.
    *
    * @param make Manufacturer
    * @param model Model of car
    * @param yearBuilt Year that car was made
    * @param color Color of car 
    */
    Car (String make, String model, String yearBuilt, String     | color) {
        this.make = make;
        this.model = model;
        this.color = color;
        this.yearBuilt = yearBuilt;
    }
 
   /**
    * Get the make of car.
    * @return car Make
    */
    public String getMake() { return make; }
 
   /**
    * Get the model of car.
    * @return car Model
    */
    public String getModel() { return model; }
 
   /**
    * Get the color of car.
    * @return car Color
    */
    public String getColor() { return color; }
 
   /**
    * Get the year of car.
    * @return car Year
    */
    public int getYear() { return year; } 
 
   /**
    * Speed up the car's current driving pace.
    * @param increment Amount to speed up by
    * @return currentSpeed The now currentSpeed
    */
    public int speedUp(int increment) {
        currentSpeed += increment;
        return currentSpeed;
    }
 
   /**
    * Slow up the car's current driving pace.
    * @param decrement Amount to slow down by
    * @return currentSpeed The now currentSpeed
    */
    public int slowDown(int decrement) {
        currentSpeed -= decrement;
        return currentSpeed;
    }
 
   /**
    * Play tape player.
    * @deprecated People don't listen to tapes anymore
    * @param cassetteName Name of tape to play
    */
    public void playTape(String cassetteName) {
            
    }
 
   /**
    * Turns on AUX cable.
    * @since version 2.0.0
    * @param inputGadget The gadget that is being plugged in
    */
    public void playAux(String inputGadget) {
 
    }
}

Take your Linux skills to the next level!

The Linux Command Line

Take your Linux skills to the next level! Try Linux & UNIX

The Linux Command Line takes you from your very first terminal keystrokes to writing full programs in Bash, the most popular Linux shell. Along the way you'll learn the timeless skills handed down by generations of gray-bearded, mouse-shunning gurus: file navigation, environment configuration, command chaining, pattern matching with regular expressions, and more.

$ Check price
39.9539.95Amazon 4.5 logo(274+ reviews)

More Linux & UNIX resources

Learn Enterprise Java Development for a Bright Career

Core Java, Volume II

Learn Enterprise Java Development for a Bright Career Try Java

Designed for serious programmers, this reliable, unbiased, no-nonsense tutorial illuminates advanced Java language and library features with thoroughly tested code examples. As in previous editions, all code is easy to understand and displays modern best-practice solutions to the realworld challenges faced by professional developers.

$ Check price
59.9959.99Amazon 4 logo(34+ reviews)

More Java resources

Ad