3

OK. There appears to be lots of information out there on how to do this but I'm not getting the information in my javadoc for the package description. Plus, I'm a little (or a lot) confused about the exact procedure on how to do this.

I've created a package-info.java class as specified in this answer.

/*
 * Package description that I want to get added to my javadoc
 */
package com.pdl.myapp;

But when I run generate javadocs nothing appears in the description for the package in the javadocs.

enter image description here

Then I tried using package level annotations as described in this answer but got very confused about exactly what to put to replace the // stuff as required.

Here is my package-info.java class. Notice the @PackageLevelAnnotation annotation has been added.

/*
 * Package description that I want to get added to my javadoc
 */
@PackageLevelAnnotation
package com.pdl.myapp;

Here is my

package com.pdl.myapp;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 *
 * @author Miss Lucy
 */
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.PACKAGE)
public @interface PackageLevelAnnotation {
    // stuff as required  <----- WHAT IS THIS?
    // How do I add my package description?
    // Package description that I want to get added to my javadoc
}

Call me dumb but I am just not getting it. Can someone give me specific information or point me to this topic for Dummies?

Community
  • 1
  • 1
Patricia
  • 5,019
  • 14
  • 72
  • 152

1 Answers1

4

It looks like you are using the wrong comment style.

/* <--- note one asterisk.
 * You are using this, this does not generate java docs.
 */

In your package-info.java file include a java doc comment above the package. For example:

 /** <--- note two asterisks.
  * This is my package description
  */
 package com.blam.kapow;
DwB
  • 37,124
  • 11
  • 56
  • 82
  • Please where is the **package-info.java** file located? – Moz Jun 11 '21 at 12:29
  • 1
    Every package may contain a package-info.java file; it is located in the package. – DwB Jun 11 '21 at 13:22
  • Thanks! I know **IDEs** like InteliJ, Eclipse and NetBeans has an option that automatically does it for us under a menu, but unlucky for me because I haven't installed any yet so I'm using **NotePad++** to code so I have to do things manually and understand after viewing this link https://github.com/eugenp/tutorials/tree/master/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/finalkeyword – Moz Jun 11 '21 at 14:03
  • "located in the package" in java terms translates to "located in the directory that represents the package on the disk" – DwB Jun 11 '21 at 14:38