5

can any body please tell me how to create package-info.java file in netbeans,when i am trying to create a new java file with name package-info to specify a package level annotation,class name is not valid error is thrown

Thanks in advance

user1740005
  • 567
  • 1
  • 7
  • 17
  • It is possible to create such a file in NetBeans, ever since this bug https://netbeans.org/bugzilla/show_bug.cgi?id=60949 was fixed. – Enwired Sep 12 '13 at 17:30

2 Answers2

8

The package-info.java is not exactly a java source file.

The proper way is, when you create a new file, do not create a Java Class file. Instead, create a Java Package Info file, also in the Java category. This will trigger the New Java Package Info wizard.

enter image description here

Sheepy
  • 17,324
  • 4
  • 45
  • 69
  • Choose `Tools > Templates > Open in Editor` to verify correct documentation comment syntax, `/**…*/`, cited [here](https://stackoverflow.com/a/3644733/230513); some versions generate a traditional comment, `/*…*/`, which the doclet ignores. – trashgod Sep 24 '21 at 02:06
5

That's not completely correct. You can create a file under Other > Other > Empty File with name package-info.java

You can place there the Javadoc comments for the package and the "package" line:

/**
 * Here are some comments about this package.
 * Here is a comment linking to {@link java.lang.Object}.
 */
package packagename;
Enwired
  • 1,563
  • 1
  • 12
  • 26
user2086741
  • 51
  • 1
  • 2