I use the javadoc @version tag in my classes, however I am not sure how to get the version in the class itself. Let’s look at an example…
/**
* @version 1.0a
* @author Redandwhite
*/
public class JClass extends JFrame implements ActionListener, KeyListener {
String version = ...
}
Is there a method/class that can retrieve the version? Ideally, it’s as simple as an API call which returns a simple String.
The javadoc comments are not included in the generated byte code in any form, so there is no way to access the value of the @version tag from Java code (unless you parse the source code of course). There might be a version annotation that can be used to specify the class version instead of or in addition to the javadoc @version tag, and this annotation would be accessible via the Java reflection API (i.e.
Class.getAnnotations()).