title: Automatically connect to internet when network is available
body: <p>I have to develop an application which collects some data(from databases or flat files or something else) and connect to a server which is a repository and store the data in it.<br>
  The functional requirement is:</p>
  
  <ul>
  <li>client application must detect available network</li>
  <li>connect to network automatically</li>
  <li>ask user for authentication ... for eg: internet </li>
  </ul>
  
  <p>Any one please suggest me what API I should use.<br>
  Is it possible using java?</p>