Ky -
Ky -

Reputation: 32143

Java battery meter for Windows

I want to make a battery meter for my computers, which all work on different OSs. I figured the best way would be in Java. Is there any way to do this WITHOUT external libraries? All it needs to do is show the battery level in a java.swing.JProgressBar.

Upvotes: 0

Views: 650

Answers (2)

donnyton
donnyton

Reputation: 6054

Even within the OS, the battery level is a very low-level measurement that is really carried out by the hardware.

At the very least, you would have to use external libraries to do it, but even if you do, there's a good chance that you still wouldn't have a cross-platform solution due to the very different ways batteries are handled by both OS and hardware.

Upvotes: 2

aroth
aroth

Reputation: 54846

No, there is no way to do this just using the standard JDK. It is up to the OS to expose details about the current power/battery state, and there is no built-in way to access this information in Java. To do what you want will require at least some external libraries, and almost certainly JNI as well.

Upvotes: 6

Related Questions