0

Recently had a problem with

java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available

Tried to isolate the problem, using this simple code:

import java.security.NoSuchAlgorithmException;

import javax.crypto.Mac;

public class Main {
  public static void main(String... args) {

      final String HMAC_SHA1_ALGORITHM = "HmacSHA1";
      Mac instance;
      try {
          instance = Mac.getInstance(HMAC_SHA1_ALGORITHM);
      } catch (NoSuchAlgorithmException e) {
          final String errmsg = "NoSuchAlgorithmException: "
                  + HMAC_SHA1_ALGORITHM + " " + e;
          // ...
      }

  }
}

The thing is that this works in one of my Eclipse instances, and not on the other. All tested using New Java Project, pasting the above, and running, so this should be due to some settings difference between the Eclipse instances.

I've tried to look through all the seemingly relevant settings (classpath, JRE, java compiler), but nothing that looks different or makes it work if changed. (If someone knows how to 'diff' the settings of two Eclipses, do tell!)

I'm resorting to simply using a third Eclipse (where it works (so far)), but it would still be interesting to learn what this potentially infuriating problem is really down to.

2
  • Possible instance of this?: stackoverflow.com/questions/2856248/… Commented Sep 7, 2012 at 13:24
  • Well I had read that question, and I suppose it's possibly related, but as that is started by a script ("The startup script...") I thought it would be different enough to not be relevant. I tried the 'addProvider()' part of it, made no difference. It would be extremely odd if the library was in some 'wrong place', I think. And it works in one of the Eclipses, so it should (but you never know) be something to do with Eclipse, I think. Commented Sep 7, 2012 at 14:08

1 Answer 1

0

I had that same Exception using Eclipse and tomcat, what I did was :

Reload JDK over TOMCAT 8 configuration, and it started working

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.