---
title: Java library versioning for code access
description: Most code libraries have versions. Versioningis one of those generally Good Things.Yesterday@danmiland I were looking to see what specificHadoopversi
---

[Blog - HubSpot Product Team ](https://product.hubspot.com/blog)

# [Java library versioning for code access](https://product.hubspot.com/blog/bid/6007/java-library-versioning-for-code-access)

 Written by [Yoav Shapira](https://product.hubspot.com/blog/author/yoav-shapira) | Jun 26, 2009

Most code libraries have versions.  [Versioning](http://en.wikipedia.org/wiki/Revision_control) is one of those generally Good Things.

Yesterday [@danmil](http://twitter.com/danmil) and I were looking to see what specific [Hadoop](http://hadoop.apache.org/core/) version was installed on a node in our EC2 cluster.

While Java has several mechanisms to specify library versions in a declarative way, especially when packaging a JAR or using a system like Maven, it doesn't seem like there's a standard for querying said version in code.

Hadoop has a command-line option to print out the version of the library.  There is a custom little Hadoop class, [VersionInfo](http://hadoop.apache.org/core/docs/r0.18.3/api/org/apache/hadoop/util/VersionInfo.html), with an annotation that specifies the version.

This is not bad.  It's useful, and it works.  Except yesterday, it said the version was unknown ;)

We eventually figured it out, we think, but the episode was interesting.

Is there some standard way to find the version of a Java library you're using, at runtime, from code?  Maybe something [JMX](http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/)-related?  If not, what's the best system you've seen?

Do other languages do better in this area?  What does Python or PHP do?  C#?

I'm not talking about a way for a sys admin to click around or view file versions.  It's a way for one piece of code (maybe in the same JVM, in the Java case, but not necesssarily).

 http://dev.hubspot.com/bid/6007/Java-library-versioning-for-code-access

[View full post](https://product.hubspot.com/blog/bid/6007/java-library-versioning-for-code-access)

```json
{
  "@context" : "http://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Yoav Shapira"
  },
  "dateModified" : "2020-09-29T23:20:42.129Z",
  "datePublished" : "2009-06-26T14:58:00Z",
  "headline" : "Java library versioning for code access",
  "image" : {
    "@type" : "ImageObject",
    "height" : 512,
    "url" : "https://f.hubspotusercontent40.net/hubfs/51294/library.png",
    "width" : 1024
  },
  "mainEntityOfPage" : "https://product.hubspot.com/blog/bid/6007/java-library-versioning-for-code-access",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "height" : 60,
      "url" : "/hs/hsstatic/content_shared_assets/static-1.4092/img/default-amp-logo.png",
      "width" : 60
    },
    "name" : "HubSpot Product Blog"
  }
}
```