?
Solved

How to use Java to detect LAN cable unplug?

Posted on 2009-03-31
7
Medium Priority
?
761 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

765 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