Post Tweets using java


I’ve written a simple web application, which I want to be able to post tweets.

I have seen some java libraries for working with Twitter, but they all seem like too much of work for something that is seemingly simple. Is it possible that I am missing something?

Is there any simple way to post a tweet in twitter from a web-app in java with only a few lines of code?


How about Twitter4J?
It’s powerful, but simple.


Thanks Yusuke Yamamoto ,

In This , There Is Some Manual Work , I Have To Copy Authorization URL and paste in browser , From there i have to copy Pin And Give as Input , I Want to do this process automatic

Thanks In Advance


Will you be posting tweets on the application’s behalf or on behalf of your users? If you want to offer a simple way for your own users to Tweet from your site without having to learn about authentication, check out [node:183,title=“Web Intents”].

As for the copying and pasting in the browser/PIN input/etc comment about OAuth: for a web-based application, it’s much simpler than all that. Especially if you’re using a library like Twitter4J. Your server issues a request to Twitter. Your server redirects the user to Twitter’s OAuth screen. Twitter redirects the user back to your server. You issue another sever-to-server request to Twitter to obtain the user’s authorization and then you’re done.

But if you’re looking for the simplest possible integration points, Web Intents are a good fit. They’re just links.


Hi Yusuke, I wrote a java program which analyse sentences to determine whether they are positive or negative. The actual project is “Sentiment Analysis on Twitter” which actually is supposed to retrieve tweets on topics (through search), then analyse each tweets to determine peoples opinion on that particular topic or keyword.

I have ran the code you posted on, but it is not working. The output is always:
java [query]
Java Result: -1.

Give can you send me a tutorial on how to search and retrieve tweets into my java (netbeans) project.

kind regards,



but, I thought by using Scribe library is enough for doing tweet status via java app…?
Have anyone of u used the Scribe Library? Here:
have a try!
Because I also confused lol. My first time creating tweet app under java envi.


hello, how do you get the id device type with the twitter4j?


Hi Yusuke, I found your old example code from the Pebble github project. Is this still working? I tried your old Pebble OAuthUpdate commandline example using a new Twitter key and secret but it only returns: Twitter4j 2.0.10

I know this is an old tweet but this is the newest I could find on Google.

Any ideas of how to get tweet posts working again using twitter4j.jar (if it is still maintained?).


I didn’t get the pin number when i access the authoriztion url…Please help me with this…


pls what if i want to tweet from an android application and receive the mention, how can i do dat?