开发者

What is annotation processing in Java?

Quoting, Sun's Official Java Tutorial

Class names, 'HelloWorldApp',开发者_开发技巧 are only accepted if annotation processing is explicitly requested

What does it mean? And how to apply it?


"Annotation Processing" is a hook into the compile process of the java compiler, to analyse the source code for user defined annotations and handle then (by producing compiler errors, compiler warning, emitting source code, byte code ...).

API reference: javax.annotation.processing (Java Platform SE 6).


From the very next line of the page that you refer to:

Class names, 'HelloWorldApp', are only accepted if annotation processing is explicitly requested

If you receive this error, you forgot to include the .java suffix when compiling the program. Remember, the command is javac HelloWorldApp.java not javac HelloWorldApp.

That is, the string that you are referring to is a possible error that you might get when trying to compile the examples. The very next line in the document, tells you how to resolve the issue.

If you want to know more about annotations, what they are, and how to use them, then I would suggest to go through the Annotations tutorial.


This error is due to incorrect use of java compilation command i.e javac with file name w/o java extension (.java)

Use proper compilation command

javac HelloWorldApp.java

Command used foe execution

java HelloWorldApp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜