It looks like you are attempting to connect with
null as the
Authenticator. It
should be throwing an
AuthenticationFailedException which would be picked up by the catch exception block at the end. For the record; this is not a good idea because it can introduce bugs that are nearly impossible to track down. Try to catch the specific exception that the code may throw (your IDE will help you with this). I do not know why it would be timing out instead of throwing an exception but at a guess I would say it has something to do with google's security system. It would make sense for a massive system like gmail to timeout a bad authentication because it would make it harder to brute force someone's password (this is a un-educated guess mind you).
You can read up on the Authenticator
here.
As a side note, your comment states: "host,user password and iinternet coneection are provided correctly". Assumptions are the cause of all f***-ups and I do not see any code that checks these parameters and fails gracefully for bad input. Given that you failed to spell 'internet' and 'connection' correctly it stands to reason you are not passing the correct parameters as command line arguments.