title: messagedigest object throws NoSuchAlgorithm when used as a field/static variable in java
body: <p>I am able to call MessageDigest as a local variable in main() method of my code, but whenever I try creating a field variable of MessageDigest in a class, and try initializing it in a constructor, it throws a NoSuchAlgorithm exception. </p>
  
  <p>My gut feeling is that we just cannot instantiate MessageDigest objects like that. Is that true?</p>
  
  <p>Basically, <a href="http://www.mkyong.com/java/java-sha-hashing-example/" rel="nofollow">this is</a> what I did. I want to use this as a field variable, and not a local variable.</p>