Hi guys!

i'd like to ask is there any way to listen the system's sleep(hibernate or suspend...) and awake event?

cause i'm making a java application,and i need to do some thing when the system begin to sleep and awake,but i don't know how to get to knows there events(and other system events,like inserting a usb device...)

Or is there any api method in java or C++?

Pls,help me,i really need to know!
Thanks so so so much in advance!!!