java.net.Authenticator and java.net.PasswordAuthentication do not deal with HTML-FORM base anthentication, and there is no standard way how do peoples define their HTML username and password fields. If you are making a generic utility to do this job, it would be a pretty hard task. in your
java code, you have to parse HTML page which has username and password field on it, to get input field name of these two field and Action URL then using HTTP POST in your URLConnection code to open connection.
for specific web site, you do not need to parse HTML page. you can find these information advance.
third way, You can develop a simple WEB browser to do this trick.