I want to be able to detect when a computer connects to a network. The environment is Java 5 under Windows.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think your choices are to either use some JNI library (though I’m not familiar with one offhand and that would tend to be platform specific), or just try making a network connection to some known IP (google for example). Neither solution is elegant, but I don’t believe there is a pure Java API in 1.5 for determining this.
In Java 1.6, you could use java.net.NetworkInterface.isUp(), but obviously that won’t help for your case of using 1.5.