I've had to confirm which JAXB
version I've been using for my runtime. In my search through various forums I've come across some code that more or less worked, but it wasn't very robust and wasn't explained well. I've put this together to answer the question properly.
This code will determine which JAXB-RI runtime version is being used. This will not work for Moxy or any other JAXB implementation other than the V2 RI. I could not find the equivalent code for Moxy, so instead of the code failing with a ClassCastException, I make sure that the V2 RI is being used before trying to get the version number.
My output is something like this:
A quick disclaimer...
Although I put in a great effort into researching all the topics I cover, mistakes can happen.
Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.
All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle).
Use of any information contained in this blog post/article is subject to this disclaimer