0

Can anybody help me with java code to monitor system power,that is to check if a machine is running on battery or on ac power

5
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by mukorera
0

Thank you.In that case Can i have help with the c or c++ code that can be used for this,maybe i can then integrate this with java

0

This is Java section. You either have to create new thread there (and please "Mark As Solved" this), or tell me now and I can move whole this thread to one of the sections.

0

Lets not give up so soon!
Under Vista and Win 7 there is a system API for this which is very easy to access via JavaScript. Under Java 6 it's very easy to embed JavaScript. I'm betting you can call afew lines of JavaScript directly from a Java method to get the desired info

1

Don't have it in front of me now, but its part of the support for the vista/w7 sidebar. sidebar.exe is also a COM automation / activeX server that gives access to stuff that sidebar gadgets like to display, and battery power info is in there as well. I found jscript gadget examples that accessed System.Machine.PowerStatus.batteryPercentRemaining from that COM interface.
I guess the rest is just plumbing, although there's maybe some implicit bit of initialisation that Gadgets have that will also be needed.

Votes + Comments
Thanx for info
0

this can be surely done by java,all u have to is make a socket program and get the oid values of mib database of snmp chip.

1

Managed to get some tips from the c forum and It can be done using java,especially using linux.
all u need to do is access the file state from /proc/acpi/ac_adapter/ACAD/ and use the information you read from the file to check if ac power is plugged in or not,u'll just use simple if statements,thank you all for your contribution

Votes + Comments
Thank you for sharing
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.