Solved

How to use Java to detect LAN cable unplug?

Posted on 2009-03-31
7
710 Views
Last Modified: 2012-05-06
Hi all

Is there any ways in which I can use Java to detect the event whereby user unplug the LAN cable so that I can do something like turning my icon to another one so as to show it is offline.

I got a way in which a timer where by i check my ipaddress to local host, but it is quite a expensive way to perform checks in a infinite timer to check every 10 mins.

Appreciate if someone has an answer to it
0
Comment
Question by:stelectronic
7 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 total points
ID: 24029550
>> but it is quite a expensive way to perform checks in a infinite timer to check every 10 mins.

You won't find anything much 'cheaper'. Even if you could find something lower level, it would only be doing something similar so it could generate events
0
 
LVL 3

Expert Comment

by:techmaza
ID: 24029556
U can send ping IP packet thru java.net package every 30 sec time interval and if user on target computer removes the lan cable then connection will be lost and u will catch an exception  which u can use to trigger an ballon tip event message.
0
 

Author Comment

by:stelectronic
ID: 24029710
Is there a way in which Java can use Windows event? something like when I unplug a LAN cable, windows will notify me. is there a way for me to capture/hook on that event using listeners?

The reason I dun want to use timers is that it might have out of memory exception if it is allowed to run a long time.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Expert Comment

by:defi0
ID: 24030723
You could do it within a DLL that you would call using JNI. But it's not straightforward to build.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24030862
>>The reason I dun want to use timers is that it might have out of memory exception if it is allowed to run a long time.

There's no necessary connection between daemon processes/threads and memory problems.

>>is there a way for me to capture/hook on that event using listeners?

How, do you imagine, would kernel level functionality manage to listen for such events?
0
 
LVL 92

Expert Comment

by:objects
ID: 24034482
There are no events available for this, what you are already doing is the best you can do.
A Timer would be the best for minimizing the memory usage.

http://helpdesk.objects.com.au/java/how-to-execute-code-at-regular-interval

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now