28

I'm trying to find some information on what the package-info.java file generated by the JAXB xjc commandline app actually does. All that is in the file is

@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.example.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package the.generated.package.path;

What is this package-info.java file used for?

E-rich
  • 9,243
  • 11
  • 48
  • 79
  • 29
    That search actually isn't very helpful. Isn't it better to link directly to questions that you think provide useful information, rather than a search page which can change over time? – kittylyst Sep 23 '11 at 13:35

3 Answers3

28

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).

eiselems
  • 170
  • 1
  • 12
piepera
  • 2,033
  • 1
  • 20
  • 21
7

This is also useful when you generate javadoc

package-info.java - Can contain a package declaration, package annotations, package comments and Javadoc tags. This file is new in JDK 5.0, and is preferred over package.html.

source : http://download.oracle.com/javase/6/docs/technotes/tools/solaris/javadoc.html#sourcefiles

kdabir
  • 9,623
  • 3
  • 43
  • 45
0

If you want to define default namespace for elements in your java model, you can define it in package-info.java

Kunal Khanna
  • 551
  • 6
  • 6