B4J Library (b4j)[jpadina] Get Unique hardware ID

Get Unique hardware ID in b4j
tested on windows only you can test on mac or linux

8 method to get Unique hardware id

b4j.png




changeLog :
1. fix error in none_ui apps
2. removed all unnecessary methods
3. two new method added
Log(pdd.Get_HWID1)
Log(pdd.Get_HWID2)


How Use :
B4X:
    Dim pdd As Padina_Lib
 
    Log(pdd.Get_CPUID )
    Log( pdd.Get_HddID1 )
    Log( pdd.Get_HddID2 )
    Log ( pdd.Get_MachineID )
    Log ( pdd.Get_MacId )
    Log ( pdd.Get_MotherboardSN )
    Log( pdd.Get_HWID1 )  'hardware + software > can change with changing windows or user
    Log( pdd.Get_HWID2 )  'hardware + software > can change with changing windows or user

lib (jar and xml files) atteched.
 

Attachments

  • jpadina v1.8.zip
    8.3 KB · Views: 74
Last edited:

Chris2

Active Member
Licensed User
Thanks for sharing this @behnam_tr.
It generates an error when used in a non-ui app though...
Waiting for debugger to connect...
java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at ir.padina.Padina_Lib.<clinit>(Padina_Lib.java:261)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:522)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:509)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:252)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at b4j.example.main.<clinit>(main.java:17)
Caused by: java.lang.ClassNotFoundException: javafx.scene.control.Alert$AlertType
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 14 more
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:137)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at b4j.example.main.<clinit>(main.java:17)
Caused by: java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at ir.padina.Padina_Lib.<clinit>(Padina_Lib.java:261)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:522)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:509)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:252)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
... 2 more
Caused by: java.lang.ClassNotFoundException: javafx.scene.control.Alert$AlertType
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 14 more
 

behnam_tr

Active Member
Licensed User
Thanks for sharing this @behnam_tr.
It generates an error when used in a non-ui app though...
Waiting for debugger to connect...
java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at ir.padina.Padina_Lib.<clinit>(Padina_Lib.java:261)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:522)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:509)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:252)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at b4j.example.main.<clinit>(main.java:17)
Caused by: java.lang.ClassNotFoundException: javafx.scene.control.Alert$AlertType
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 14 more
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:137)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at b4j.example.main.<clinit>(main.java:17)
Caused by: java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at ir.padina.Padina_Lib.<clinit>(Padina_Lib.java:261)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:522)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:509)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:252)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
... 2 more
Caused by: java.lang.ClassNotFoundException: javafx.scene.control.Alert$AlertType
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 14 more


Hi
I will try to check tonight
seems related to the mymsgbox class
i will remove it from Lib
 
Last edited:

behnam_tr

Active Member
Licensed User
New Version 1.6

fix error in none_ui apps

B4X:
    Dim pdd As Padina_Lib
    
    Log(pdd.Get_CPUID )
    Log( pdd.Get_HddID1 )
    Log( pdd.Get_HddID2 )
    Log ( pdd.Get_MachineID )
    Log ( pdd.Get_MacId )
    Log ( pdd.Get_MotherboardSN )
 

Attachments

  • jpadin 1.6.zip
    8 KB · Views: 41

Chris2

Active Member
Licensed User
Thanks for your efforts, but I still get the error, with a slightly different 2nd line...
Waiting for debugger to connect...
java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at ir.padina.Padina_Lib.<clinit>(Padina_Lib.java:248) <------------- 248 as opposed to 261 before
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:522)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:509)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:252)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at b4j.example.main.<clinit>(main.java:17)
Caused by: java.lang.ClassNotFoundException: javafx.scene.control.Alert$AlertType
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 14 more
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:137)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at b4j.example.main.<clinit>(main.java:17)
Caused by: java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at ir.padina.Padina_Lib.<clinit>(Padina_Lib.java:248)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:522)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:509)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:252)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
... 2 more
Caused by: java.lang.ClassNotFoundException: javafx.scene.control.Alert$AlertType
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 14 more
 

behnam_tr

Active Member
Licensed User
Thanks for your efforts, but I still get the error, with a slightly different 2nd line...
Waiting for debugger to connect...
java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at ir.padina.Padina_Lib.<clinit>(Padina_Lib.java:248) <------------- 248 as opposed to 261 before
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:522)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:509)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:252)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at b4j.example.main.<clinit>(main.java:17)
Caused by: java.lang.ClassNotFoundException: javafx.scene.control.Alert$AlertType
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 14 more
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: java.lang.RuntimeException: java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:137)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at b4j.example.main.<clinit>(main.java:17)
Caused by: java.lang.NoClassDefFoundError: javafx/scene/control/Alert$AlertType
at ir.padina.Padina_Lib.<clinit>(Padina_Lib.java:248)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:522)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:509)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:252)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
... 2 more
Caused by: java.lang.ClassNotFoundException: javafx.scene.control.Alert$AlertType
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 14 more

are you using java 8 or 11?
i test with java8 without any error
clean project and check lib version(1.6)
 

Chris2

Active Member
Licensed User
are you using java 8 or 11?
i test with java8 without any error
clean project and check lib version(1.6)
Java 11. Which seems to be the problem. It works for me too with Java 8.
I'm just testing with a basic non-ui app:
B4X:
'Non-UI application (console / server application)
Sub Process_Globals
    Private uid As Padina_Lib
End Sub

Sub AppStart (Args() As String)
    Log("Hello world!!!")
    Log(uid.Get_CPUID )
    Log( uid.Get_HddID1 )
    Log( uid.Get_HddID2 )
    Log ( uid.Get_MachineID )
    Log ( uid.Get_MacId )
    Log ( uid.Get_MotherboardSN )
End Sub
 

behnam_tr

Active Member
Licensed User
updated to 1.8

2 new method added

Log(pdd.Get_HWID1)
Log(pdd.Get_HWID2)
 

Attachments

  • jpadina 1.8.zip
    8.3 KB · Views: 52

behnam_tr

Active Member
Licensed User
Good job
What kind of hardware do the last two functions Get_HWID1 and Get_HWID2 detect?

Runtime.getRuntime().availableProcessors() + System.getenv("PROCESSOR_IDENTIFIER") + System.getenv("PROCESSOR_ARCHITECTURE") + System.getenv("PROCESSOR_ARCHITEW6432") + System.getenv("NUMBER_OF_PROCESSORS");
 

amorosik

Well-Known Member
Licensed User
Hi behnam, i would like to point out that in the Windws Xp 32 bit environment, using B4J 7.32 + Jdk 1.8.0.40 x86, the library is unable to return the functions:
- Get_HddID2
- Get_machineID
As soon as the functions are recalled, the program stops and it is no longer possible to continue
 

behnam_tr

Active Member
Licensed User
Hi behnam, i would like to point out that in the Windws Xp 32 bit environment, using B4J 7.32 + Jdk 1.8.0.40 x86, the library is unable to return the functions:
- Get_HddID2
- Get_machineID
As soon as the functions are recalled, the program stops and it is no longer possible to continue

Some methods may not be available on different hardware or operating systems. You can and should use other methods or a combination of methods that have the correct output.

B4X:
Sub get_serial As String
    
    Dim pdd As Padina_Lib
    Dim sr As String=pdd.Get_MotherboardSN
    If sr<>Null And Not(sr.Contains("O.E.M")) Then
        sr=pdd.Get_MotherboardSN
    
    Else If pdd.Get_CPUID<>Null Then
        sr = pdd.Get_CPUID
    
    Else If pdd.Get_MachineID<>Null Then
        sr=pdd.Get_MachineID
    
    Else If pdd.Get_HddID1<>Null Then
        sr=pdd.Get_HddID1
    
    Else If pdd.Get_HddID2<>Null Then
        sr=pdd.Get_HddID2
        
    Else If pdd.Get_MacId<>Null Then
        sr=pdd.Get_MacId
        
    End If
    
   Return sr

End Sub

also download last update(1.8) from first post
 
Last edited:
Top