Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8517777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:47:59+00:00 2026-06-11T05:47:59+00:00

In my project I am trying to integrate twitter using twitter4j .I tried sample

  • 0

In my project I am trying to integrate twitter using twitter4j.I tried sample code to login in office and I could post tweet successfully using that,but coming back to home I am facing bizarre problem in JCE.Jar which says

Failed to get HmacSHA1 "Message Authentication Code" (MAC)
  java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available
at javax.crypto.Mac.getInstance(DashoA13*..)
at twitter4j.auth.OAuthAuthorization.generateSignature(OAuthAuthorization.java:317)
at twitter4j.auth.OAuthAuthorization.generateAuthorizationHeader(OAuthAuthorization.java:227)
at twitter4j.auth.OAuthAuthorization.generateAuthorizationHeader(OAuthAuthorization.java:273)
at twitter4j.auth.OAuthAuthorization.getAuthorizationHeader(OAuthAuthorization.java:75)
at twitter4j.internal.http.HttpClientImpl.setHeaders(HttpClientImpl.java:237)
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:113)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
at twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:102)
at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:121)
at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:104)
at twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:276)
at twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:269)
at org.twitterstats.App.main(App.java:23)
   Exception in thread "main" java.lang.AssertionError: java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available
at twitter4j.auth.OAuthAuthorization.generateSignature(OAuthAuthorization.java:337)
at twitter4j.auth.OAuthAuthorization.generateAuthorizationHeader(OAuthAuthorization.java:227)
at twitter4j.auth.OAuthAuthorization.generateAuthorizationHeader(OAuthAuthorization.java:273)
at twitter4j.auth.OAuthAuthorization.getAuthorizationHeader(OAuthAuthorization.java:75)
at twitter4j.internal.http.HttpClientImpl.setHeaders(HttpClientImpl.java:237)
at twitter4j.internal.http.HttpClientImpl.request(HttpClientImpl.java:113)
at twitter4j.internal.http.HttpClientWrapper.request(HttpClientWrapper.java:65)
at twitter4j.internal.http.HttpClientWrapper.post(HttpClientWrapper.java:102)
at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:121)
at twitter4j.auth.OAuthAuthorization.getOAuthRequestToken(OAuthAuthorization.java:104)
at twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:276)
at twitter4j.TwitterBaseImpl.getOAuthRequestToken(TwitterBaseImpl.java:269)
at org.twitterstats.App.main(App.java:23)
    Caused by: java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available
at javax.crypto.Mac.getInstance(DashoA13*..)
at twitter4j.auth.OAuthAuthorization.generateSignature(OAuthAuthorization.java:317)
... 12 more


 <dependencies>
  <dependency>
       <groupId>org.twitter4j</groupId>
       <artifactId>twitter4j-core</artifactId>
       <version>[2.2,)</version>
   </dependency>

Code to login into twitter is somewhat like like this.

public static void main(String args[]) thrwos Exception{
// The factory instance is re-useable and thread safe.
Twitter twitter = new TwitterFactory().getInstance();
twitter.setOAuthConsumer("[consumer key]", "[consumer secret]");
RequestToken requestToken = twitter.getOAuthRequestToken();
AccessToken accessToken = null;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while (null == accessToken) {
  System.out.println("Open the following URL and grant access to your account:");
  System.out.println(requestToken.getAuthorizationURL());
  System.out.print("Enter the PIN(if aviailable) or just hit enter.[PIN]:");
  String pin = br.readLine();
  try{
     if(pin.length() > 0){
       accessToken = twitter.getOAuthAccessToken(requestToken, pin);
     }else{
       accessToken = twitter.getOAuthAccessToken();
     }
  } catch (TwitterException te) {
    if(401 == te.getStatusCode()){
      System.out.println("Unable to get the access token.");
    }else{
      te.printStackTrace();
    }
  }
}
//persist to the accessToken for future reference.
storeAccessToken(twitter.verifyCredentials().getId() , accessToken);
Status status = twitter.updateStatus(args[0]);
System.out.println("Successfully updated the status to [" + status.getText() + "].");
System.exit(0);
 }
private static void storeAccessToken(int useId, AccessToken accessToken){
  //store accessToken.getToken()
  //store accessToken.getTokenSecret()
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:48:00+00:00Added an answer on June 11, 2026 at 5:48 am

    Though I am not very sure why this problem occurred but just attempted version upgrading to Java 7 and it worked!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to integrate Brad Larson's GPUImage framework to my project. The sample code
I am trying to integrate an openID login in a ZF project (using the
I am trying to integrate the following code into my project. it is held
I'm trying to integrate Google Analytics into my Android project using the information on
Okay, I am trying to integrate some C code into a C++ project, and
I am trying to integrate saleforce with my project. While accessing the url /chatter/feeds/files/me
I'm trying to integrate FNV hashing algorithm on a PHP-based project as part of
I'm trying to integrate an adaptive payments system to my codeigniter project on my
I am currently trying to integrate Paypal's MECL in an already existing IOS project
I'm trying to integrate Sugar CRM with one of my projects. I'm using Apache

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.