Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create package-info.java file in netbeans?

Tags:

java

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

like image 678
user1740005 Avatar asked Nov 03 '12 04:11

user1740005


People also ask

How do you create a package-info class?

Creating a package-info file is fairly simple: we can create it manually or seek IDE help for generating the same. In IntelliJ IDEA, we can right-click on the package and select New-> package-info. java: Eclipse's New Java Package option allows us to generate a package-info.

What is a package-info file?

The package-info. java is a Java file that can be added to any Java source package. It is used to provide info at a "package" level as per its name. It contains documentation and annotations used in the package.

What is Package-info Java in JAXB?

package-info. java is a way to apply java annotations at the package level. In this case Jaxb is using package-level annotations to indicate the namespace, and to specify namespace qualification for attributes (source).

What is package HTML?

A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar to different folders on your computer. You might keep HTML pages in one folder, images in another, and scripts or applications in yet another.


2 Answers

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

like image 58
Sheepy Avatar answered Sep 28 '22 04:09

Sheepy


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;
like image 23
user2086741 Avatar answered Sep 28 '22 04:09

user2086741