First download the tar file of java version u required. Follow I downloaded 1.7
You will need sudo privileges to perform this task:
sudo su
sudo su

This will help you to detect network changing states in android phone. For get an idea abut the API use for this read Followings. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
Now you good to go with the creating of your service.