I am currently working on creating a nifty utility that will beep once the laptop’s battery is at 55% or at whatever percent the user wants to get notified.
I was told that Java does not provide any access to this information and for that I will need to use JNA(Java Native Access) by Todd Fast.
I got the jna.jar file downloaded but I don’t know what to do next to create that software.
I was helped by a community member who created a code that does just that and it is here:
How to get the remaining battery life in a Windows system?
In the code he leaves a comment Fill The Structure. This is where I get confused. The fill will have to be a class that implements the interface that was mentioned ?
and how do I drop jna.jar from classpath ? (and I don’t even know what that means).
I am using eclipse. I think first I will have to include the jar file as an import to the project. Guidance please.
No, the code is ready as-is. The javadoc comment merely describes method’s own sole job.
The classpath is a collection of disk file system paths to folders containing
.classfiles and/or disk file system paths to individual JAR files containing.classfiles where Java has to lookup when it needs to load a class for compile or runtime.Where and how exactly to configure the classpath in turn depends on how you’re executing the Java application. E.g. in command console, in an IDE, as a web applciation, etc.
If it’s a “plain vanilla” Java applicaiton project and you’re executing a
main()method in Eclipse by (Ctrl)F11, then you need to drop the JAR file just straight in the project root folder, rightclick it and choose Build Path > Add to Build Path. That’s it. You can manage them all in Java Build Path entry of project’s properties.