A
Arne Vajhøj
Spud said:My app needs to know what version it is, for the purpose of dumping it
in log files, etc.. The version is dynamically created at build time.
I'm thinking that the best way to do this is to put the app version in
MANIFEST.MF.
The trouble is that at runtime, I call
InputStream in =
MyClass.class.getResourceAsStream("/META-INF/MANIFEST.MF");
and it returns a reference to a MANIFEST.MF which is in some other jar
file (looks like some system jar). This makes sense; the classloader for
the current class probably loads classes from other jars as well, and
there are a lot of manifests on the classpath.
So, how do I specify which manifest to fetch?
Or is there a better way to do this? This has got to be a common
requirement...
Find the jar file your class is loaded from and read the manifest
from that using java.util.jar classes.
Arne