I want to send email from my java application to gmail account I used the following code and javaMail API ,But Gmail not accepted username and password and exception thrown
You can try to allow unsecure applications, it worked for me.
Steps for Gmail account :
See this link for Gmail and G-Suite.
To be able send mail messages via your gmail account, you should allow unsecure applications (which your application is by gmail's point of view) in google account security settings.
UPD: Also, if you want to see debug messages, use next java mail property:
props.put("mail.debug", "true");
It can help you to find out what happening behind the scenes.