Laurent Hinoul

“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.” - John F. Woods

How to display project version in Java

Sometimes, it’s useful to display the project version in your application. That version can be found in the MANIFEST.MF file. It’s located in every JAR or WAR file in the META-INF folder.

example.war -> META-INF -> MANIFEST.MF

If you open that file, you can see some project information. We need to get the Implementation-Version. Here is an example of a MANIFEST.MF file

To get that version I’ll give you a class The ‘getVersion’ method gives you that implementation-version. Don’t forget to init the class.

When you use Spring, you need to add the line below:

Hope this works for you, enjoy!

1 comment for “How to display project version in Java

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: