I am using username/password flow . I am getting access token . But when will that access token expires, so that I can request for new access token. i don't want to get access token with each request to SF. I am using it in java web application.
Simply make your API calls normally. If the session has expired, you'll get an INVALID_SESSION error (4xx error code), at which point you can simply login again. Note that sessions are valid while in use, which means as long as one API call occurs before the session expires, the timer for that session will reset.