If you have a need to maintain and report a software version number from your code, it is as simple as adding the relevant entry in the archive manifest and using something like:
Package thisPackage = this.getClass().getPackage();
String swVersion = pkg.getImplementationVersion();
No idea why I hadn't spotted that before, but I guess that either the requirement hadn't come up (unlikely) or version numbering may have been maintained using a distinct Java class instead.
Of course, if you don't package in a Java Archive, or don't include the required information in the manifest, this will return a null string, but that is a different subject...