I was wondering if there is any standard procedure to set a Java project’s version (a bit like a Windows executable file version).
I’d like to have my application’s code able to have introspection capabilities so it can know its own version.
Is it possible, at all, to do this with Java without resorting to have a .txt file in the directory with the version as contents?
If yes, the ideal would be to have Eclipse update the version each time it is compiled. Is this possible?
The Java native way to store version information is in the manifest files (this part of the tutorial is about version information).
You can use the
Packageclass and its methods such asgetImplementationVersionto get at those details at runtime.