B4J Code Snippet Hardware Health Monitor (using jsensors)

Hi there...

I am trying to create a Hardware (PC) Monitor using jSensors and jGauges !

Well i am posting here what i've done until now - it is simple... but it's a start...

What problems i am seeing:

1) Very Heavy - actually all these things using CPU a lot !! - so how it can be for health monitor when CPU is too high :-( - using Asynchronous library calls - somehow light it - but is still heavy... After that thought that if calling async alternately the sensors make it much lighter... but still heavy :-( any idea ? (found why was heavy - it is not native java... running powershell to get from wmic the temperatures/sensors values) - ... if anyone knows better way will help..

2) When i compile it - to stand alone (EXE)... and running run_debug get this error: (SOLVED) - run as administrator (b4j or the exe)
*** mainpage: B4XPage_Created
*** mainpage: B4XPage_Appear
*** mainpage: B4XPage_Resize [mainpage]
b4xmainpage._temphdd_result (java line: -1)
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 0
at b4j/b4j.example.b4xmainpage._temphdd_result(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
at b4j/anywheresoftware.b4a.BA$3.run(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
any idea ?

hwmon.jpg

You will need also jsensors jar files missing at thread of library post - you can get them from my gdrive here...

Ofcourse attaching source code - to share it and share your ideas:

Download Source Code Project from here ! (updated 16/2/2021-utc+3 19:01)
The only way to run OK this project - is to run B4J with right click Run as Administrator...
or Run the Standalone EXE (produced by B4J) with right click Run as Administrator... (after searching... for hours)
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
The app cant be run to test it , you need to export it using the
B4X:
 'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

link at the top of the B4xMainPage.
 

Magma

Expert
Licensed User
Longtime User

stevel05

Expert
Licensed User
Longtime User
I'm getting the error running the project (Not packaged). I would assume that not all disks return a temperature value. therefore the Component.Temps.length could be 0 in that situation. If you can verify that assumption it would be enough to test the length before trying to read it. Either that, or the correct values are not being returned for a particular disk.
 
Last edited:

Magma

Expert
Licensed User
Longtime User
I'm getting the error running the project (Not packaged). I would assume that not all disks return a temperature value. therefore the Component.Temps.length could be 0 in that situation. If you can verify that assumption it would be enough to test the length before trying to read it. Either that, or the correct values are not being returned for a particular disk.

Just found the reason of errors... must run B4J or standalone exe with right click "Run as administrator"

+ found why it is heavy - because no native java --- but using powershell and wmic to get values ! :-( I ve checked that at taskmgr when getting values :-(
 
Top