Better to use assembly manifest.
new Manifest(Application.class.getResourceAsStream("/META-INF/manifest.mf"))
For a specific impl version:
new Manifest(Application.class.getResourceAsStream("/META-INF/manifest.mf")) .getMainAttributes() .get(Attributes.Name.IMPLEMENTATION_VERSION)
Using maven, don't forget to create a manifest using:
<?xml version="1.0" encoding="UTF-8"?> <project> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project>
Peter Rader
source share