Create Your Own Twitter Client Using Java Programming

A twitter client does what the Twitter site does as well as the Twitter App. The main difference is this: you don’t have to use either of those two to post your random thoughts online and even photos of your drunk friends who will be fired sooner or later. Anyway, so you feel like you have had enough of this conformity stuff and you want to do things your own way – even the forces agree with you, you feel. I will show you how to achieve that! We will use Java programming language to create a simple twitter client that will post our tweets for us. Are you ready?

twitter client

The process of achieving our goal is simple and involves the following steps:

  • Create an application on Twitter’s Developer page and obtain the necessary keys and tokens – don’t sweat it because I have created a video for you to follow along if you have any issues doing so: click here to watch it. While creating your Twitter App, remember to set Access Level to Read and Write. This is because we will be posting tweets (write) to our Twitter Account.
  • Next, copy all four properties – from your Twitter Application and save them somewhere easily accessible to you: Tokens and secrets. Again, the above video will save you a lot of pain.
  • Download Twitter4j jar file and save it in your classpath inside your project folder. If you need help with this part, let me know and I can help you!
  • Now let us write some code to create our simple twitter client and be our own bosses.

Twitter Client Java Code

I used Eclipse but you can use any IDE of your choice to write this code. I could keep going on and on with this post but I would rather show you that it really works by showing you the real tweet that was sent when I clicked Run.

twitter client

So, it worked and obviously, you cannot stop here.

Where to go from here:

The fun thing to do now is to create a GUI program from this. You can have several tabs like “SendTweet” – which of course will handle inputs for tweets, another one could be “totalFollowers”, “totalRetweets”, and many more. I leave the rest to your imagination. You can also use this on your website so that you, the boss, can tweet from there without having to go to and other places just to rant.

Thank you for reading through this post on creating a twitter client. If you have questions or want to add more, please let mek now. Also, I created several examples using Python and Twitter APIs and you can find them here. Please subscribe and share this post with your cool friends online.

Written By Elisha Chirchir

Elisha Chirchir is a software developer. He is also the founder of Simple Developer and co-founder of Instinctive Software Solutions. On any given day, he works on both Android and Web Development. During his 'free time', he offers training to those interested in learning how to code in php, java, python, javaScript etc. You can easily find him on StackOverflow Android chatroom or on Twitter @Eenvincible

23 Comments on “Create Your Own Twitter Client Using Java Programming

  1. John Reply

    January 3, 2014 at 9:29

    Hi SimpleDeveloper, can you do a tutorial on how to build a java gui with twit? Thank you!

  2. Sheshnath Reply

    February 4, 2014 at 3:40

    A very nice tutorial, but please can you help me out with adding Twitter4j jar file to netbeans.

    Thank You

    • Elisha Chirchir Reply

      February 4, 2014 at 7:59

      The way to add an external library to your project depends on which IDE (Integrated Development Environment) you use. So for NetBeans, after you have downloaded your JAR file and saved it somewhere easily accessible, follow these simple steps:

      In the Projects window right-click on the name of the project that lacks library -> Properties -> The Project Properties window opens. In Categories tree select “Libraries” node -> On the right side of the Project Properties window press button “Add JAR/Folder” -> Select jars you need.

      • Sheshnath Reply

        February 6, 2014 at 6:56

        Hi thanks for your help, it worked 🙂

  3. Keyur Shah MD Reply

    February 20, 2014 at 1:27

    I need help creating a program however, I dont know how to program etc. Do you think you could reach out to me to maybe help me locate the right programming team for the job or perhaps yourself. The idea is fantastic and i know they are dime a dozen ; but its simple with huge potential.


  4. Alan Lee Reply

    March 19, 2014 at 1:41

    Hi Sir,

    I’ve done everything as according to the steps given by you. How is it that it still doesn’t work?

    • Elisha Chirchir Reply

      March 19, 2014 at 2:40

      First, make sure that you have created an app on Twitter Developer Site; you can create a new one if you think the first one is having issues. Second;y, copy all the 4 items (keys and all that ).

      You can then download the jar file, add it to your project and follow the tutorial again. If you still have any errors, let me know so I can send you the working code or help you further.

  5. SJ Reply

    March 25, 2014 at 9:17

    Hello, Im having trouble from the first line. I want to be able to get my twitter accounts followers, total tweet number, etc. I have got the keys and secret keys. using eclipse, added twitter4j.jar files. Now when trying to code, and writing,

    import twitter4j.*;
    i get error saying “import twitter4j is never used”

    How can i get my accounts imformation?

    Thanks in advance! very nice tutorial

    • Elisha Chirchir Reply

      March 25, 2014 at 9:37

      Can you paste your entire code to and share the link here so I can take a look at it? You can get your account information by just make a simple GET request instead of a POST request. Again, please show me your code by posting it on Pastebin and giving a link. Thanks

      • SJ Reply

        March 25, 2014 at 9:51

        this is what i have. Can you show me how to do the simple GET request ?

        • Elisha Chirchir Reply

          March 25, 2014 at 10:26

          It does not seem like you have much done. I am pretty sure if you copied the above code (from my tutorial) exactly as is, you should have something working and then please visit this link to learn how to use the Twitter API v1.1

  6. Aravind Reply

    January 26, 2015 at 5:58


    Is there anyway we could do the same using Facebook?


    • Elisha Chirchir Reply

      January 26, 2015 at 9:56

      You can Facebook feeds using their API. I would search on Google for more on how to do that though. Good luck.

  7. Reshma Reply

    March 3, 2015 at 2:42

    Great tutorial for amateur coders like us 🙂 Thank you so so so much! I’ve got a problem though. I added twitter4j.jar to the class path of eclipse.
    Hence im able to “import twitter4j.*;”
    However I’m getting an error in the next line which is
    “import twitter4j.auth.AccessToken;”

    What could be the problem?
    Thanks a tonne 🙂

  8. sadhana Reply

    February 7, 2016 at 6:04

    how to store and preprocess the collected tweets.
    I used eclipse and twitter4j api.

    please let me know how do to .
    thanks in advance

    • Elisha Chirchir Reply

      February 8, 2016 at 11:40

      If you are on the web, you just need a database like mySQL but on a phone, you can choose the way to go like sqlite; or RealmDB

  9. Vrinda Reply

    February 11, 2016 at 6:16

    hi.. just read about the documentation that you have mentioned.. i am facing some issues regarding the same.. can you please help me out

  10. Vrinda Reply

    February 11, 2016 at 6:22

    i am working with integration of eclipse, ruby and aptana.
    i want to create a program that makes a call to twitter api and shows the current tweets
    But i am facing problem in installing the TWITTER GEM
    Your help will be appreciated

    • Elisha Chirchir Reply

      February 13, 2016 at 9:21

      If you are using Android Studio(hopefully), you can download the jar files form Twitter4j website and add them as libraries in the libs folder of the project. That should work.

  11. Coder ACJHP Reply

    October 26, 2016 at 11:22

    All thing is OK but there is some questionmark.
    How to create login page (swing) for program users? Because after last update to Twitter api we cannot instantiate the type Twitter like this : “Twitter twitter = new Twitter(userName, password);”, because of we only can access our account?
    My mind confused so need to some body explain this for me.Thanks for tutorial.

  12. ashmeesh Reply

    December 29, 2017 at 12:53

    This tutorial was extremely helpful. However I need to make a java project on Twitter Post Ranker. Wat all do i need to do. kindly lemme know. pls this is very important.

  13. Acram Reply

    April 11, 2018 at 11:49

    Man am having problems with your code, am using Netbeans and JDK 1.8 twitter4j-4.0.4.
    import twitter4j.*; and import twitter4j.auth.AccessToken;
    gives me an error that package don’t exist. Of whic is does not.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.