Post a Tweet with twitter4j

From this response below, I think you are using this API.

401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the system clock is in sync.
{"request":"\/1.1\/media\/upload.json","error":"Read-only application cannot POST."}

As there is an error message like below you need to create a Twitter application with Read & Write permissions. For more details about error messages, check this.

Read-only application cannot POST.

Here is the official developer document about app permissions. Change this: Read only app to this: Read and write app

I hope, this is clear enough.