There are a number of properties available for configuring Twitter4J. You can specify properties via file, ConfigurationBuilder class or System Property as follows : –


Save a standard properties file named “”. Place it to either the current directory, root of the classpath directory.


By builder

You can use Builder class to configure Twitter4J programatically as follows:

Twitter twitter = Twitter.newBuilder();
  .oAuthConsumer("*********************", "******************************************")
  .oAuthAccessToken("**************************************************", "******************************************")

By System Properties

You can configure Twitter4J via System properties as well. Note that you need “twitter4j.” prefix.

$ java -Dtwitter4j.debug=true
    -cp twitter4j-core-4.0.7.jar:yourApp.jar yourpackage.Main

By Environment Variables

You can configure Twitter4J via environment variables as well. Note that you need “twitter4j_” prefix.

$ export twitter4j_debug=true
$ export twitter4j_oauth_consumerKey=*********************
$ export twitter4j_oauth_consumerSecret=******************************************
$ export twitter4j_oauth_accessToken=**************************************************
$ export twitter4j_oauth_accessTokenSecret=******************************************
$ java -cp twitter4j-core-4.1.1.jar:yourApp.jar yourpackage.Main

On Heroku:

$ heroku config:add twitter4j_oauth_consumerKey=**********
$ heroku config:add twitter4j_oauth_consumerSecret=************
$ heroku config:add twitter4j_oauth_accessToken=**************************************************
$ heroku config:add twitter4j_oauth_accessTokenSecret=******************************************
$ git push heroku master

Available Configuration Properties


Property name Description Default value
debug Enables deubg output. Effective only with the embedded logger. false
includeRTs If set to true, retweets will be included in the timeline methods’ resopnse. true
includeEntities If set to true, entities will be included in the timeline methods’ resopnse. true
includeMyRetweet set to true, any statuses returned that have been retweeted by the authenticating user will include an additional field: Status#getCurrentUserRetweetId () true
jsonStoreEnabled If set to true, raw JSON forms will be stored in DataObjectFactory. false
mbeanEnabled If set to true, mbean will be registerd. false
contributingTo sets the user id contributing to. -1L


Property name Description Default value
oauth.consumerKey Default OAuth consumer key null
oauth.consumerSecret Default OAuth consumer secret null
oauth.accessToken Default OAuth access token null
oauth.accessTokenSecret Default OAuth access token secret null


Property name Description Default value
stream.user.repliesAll enables replies=all parameter false
stream.enableStallWarnings set to true to receive stall warnings true

HTTP connection

Property name Description Default value
http.connectionTimeout Http connection timeout in milliseconds 20000
http.readTimeout Http read timeout in milliseconds 120000
http.streamingReadTimeout Streaming API’s Http Read timeout in milliseconds 300000
http.retryCount Number of HTTP retries 0
http.retryIntervalSecs HTTP retry interval in seconds 5
http.prettyDebug prettify JSON debug output if set to true. false


HTTP proxy server


Property name Description Default value
http.proxyHost HTTP proxy server host name null
http.proxyPort HTTP proxy server port null
http.proxyUser HTTP proxy server user name null
http.proxyPassword HTTP proxy server password null

Recent Posts

  1. Twitter4J 4.1.1 released Leave a reply
  2. Twitter4J 4.1.0 released Leave a reply
  3. Twitter4J 4.0.7 リリース Leave a reply
  4. General availability of Twitter4J 4.0.7 Leave a reply
  5. #Twitter4J 4.0.7-SNAPSHOT リリース – DMを利用するアプリは要移行 Leave a reply
  6. releasing #Twitter4J 4.0.7-SNAPSHOT – Apps using DM need to migrate Leave a reply
  7. #Twitter4J 4.0.4 リリース – 長文DMサポート、Lambda表記サポートなど Leave a reply
  8. #Twitter4J 4.0.4 released – supports longer DM texts, lambda expression and more Leave a reply
  9. The ultimate and complete guide to migrating to #Twitter4J 4.0.0 Leave a reply