Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

error compiling package-info.java

Thread view: 
frank - 13 Sep 2006 13:53 GMT
I'm using JAXB/xjc to generate code to access my schema.  It created a
package-info.java file along with other files.  Everything compiles fine
except for the package-info.java file it gives me an error of "package
annotations should be in file package-info.java at line 8 (8:1)"

file looks like this:
@javax.xml.bind.annotation.XmlSchema(namespace =
"urn:us:gov:dod:army:cerdec:jbfsa:csds:r1", elementFormDefault =
javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package csds.message;

it is in a file called packag-info.java, why will it not compile?

Thanks,

Frank
Andrew Thompson - 13 Sep 2006 14:03 GMT
> I'm using JAXB/xjc to generate code to access my schema.  It created a
> package-info.java file along with other files.  Everything compiles fine
> except for the package-info.java
...
> it is in a file called packag-info.java, why will it not compile?

1) So is it ..
 'package-info'
..or ..
 'packag-info'
?

2) Common nomencature for Java *classes* is
EachWordUpperCase, so that should be PackageInfo.java

And as an aside, why do you include characters like
'-' in source/class names?  It seems an 'open invitation to
a mess of trouble'.

Is this class contained in a package?

Andrew T.
Daniel Dyer - 13 Sep 2006 14:20 GMT
>> I'm using JAXB/xjc to generate code to access my schema.  It created a
>> package-info.java file along with other files.  Everything compiles fine
[quoted text clipped - 18 lines]
>
> Andrew T.

The name is correct, it's the new preferred way of providing package  
summaries for Javadoc (and for applying annotations to packages).

Unfortunately javac doesn't like it and you have to exclude it from the  
source set.

Dan.

Signature

Daniel Dyer
http://www.dandyer.co.uk

Daniel Dyer - 13 Sep 2006 19:46 GMT
>>> I'm using JAXB/xjc to generate code to access my schema.  It created a
>>> package-info.java file along with other files.  Everything compiles  
[quoted text clipped - 25 lines]
> Unfortunately javac doesn't like it and you have to exclude it from the  
> source set.

Sorry, that post wasn't as helpful as it could have been - I didn't read  
Frank's post that Andrew was responding to, and as such didn't notice that  
he was using annotations.

It's more correct to say that package-info.java was introduced to provide  
a way for annotations to be applied to packages.  A side benefit was that  
it provided a more logical place for javadoc comments for packages than  
package.html.  So far I've not needed to use it for annotations, just for  
Javadoc, so when I had problems I added an exclude pattern to the compile  
task in my Ant build files.  However, giving it some thought I couldn't  
remember exactly what led me down this path and it didn't make much sense  
that the compile should fail.  So I've just removed the exclusion from one  
of my projects and there is no complaint from the compiler (1.5.0_06 on a  
Mac).  So, either it is only a problem with certain earlier versions (this  
was a while ago with 1.5.0_something on Windows) or I had some other  
reason, that I don't recall, for wanting to exclude it.

However, if the package *is* annotated, as in the OP's example, the  
package-info.java *should* be compiled and the compiler should output a  
synthetic package-info.class (if it didn't output anything the package  
level annotations would be lost). So, returning to Frank's problem... I  
have no idea why it doesn't work :)

Dan.

Signature

Daniel Dyer
http://www.dandyer.co.uk



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.