By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account java.lang.UnsatisfiedLinkError: Can't obtain static method fromNative(Method, Object) from class com.sun.jna.Native on Windows 10 java.lang.UnsatisfiedLinkError: Can't obtain static method fromNative(Method, Object) from class com.sun.jna.Native on Windows 10 liamsharp opened this issue Mar 12, 2018 · 4 comments

Thanks for the great library guys!

Reporting the following code:

final oshi.SystemInfo systemInfo = new oshi.SystemInfo();
final String serialNumber = systemInfo.getHardware().getComputerSystem().getBaseboard().getSerialNumber();

As producing:

java.lang.UnsatisfiedLinkError: Can't obtain static method fromNative(Method, Object) from class com.sun.jna.Native
	at com.sun.jna.Native.initIDs(Native Method)
	at com.sun.jna.Native.<clinit>(Native.java:148)
	at oshi.jna.platform.windows.Ole32.<clinit>(Ole32.java:35)
	at oshi.util.platform.windows.WmiUtil.initCOM(WmiUtil.java:373)
	at oshi.util.platform.windows.WmiUtil.queryWMI(WmiUtil.java:330)
	at oshi.util.platform.windows.WmiUtil.selectStringsFrom(WmiUtil.java:256)
	at oshi.hardware.platform.windows.WindowsComputerSystem.init(WindowsComputerSystem.java:43)
	at oshi.hardware.platform.windows.WindowsComputerSystem.<init>(WindowsComputerSystem.java:38)
	at oshi.hardware.platform.windows.WindowsHardwareAbstractionLayer.getComputerSystem(WindowsHardwareAbstractionLayer.java:42)

I don't have direct access to the machine this happened on. Java 1.8.0_161 reports the OS as Windows 10, 10.0, amd64. We're using version 3.4.0 of the library.

This error is, usually, a result of an unresolved dependency on JNA.
For OSHI 3.4.0, the required JNA version was 4.2.2
You need to check that you have that.

If you ever move to the current stable version (OSHI 3.4.4), that requires JNA 4.5.0

Thanks for your response @YoshiEnVerde. I can see that JNA version 4.2.2 is being included (I'm using the Apache Maven Shade Plugin to build an uber-jar):

[INFO] Including net.java.dev.jna:jna-platform:jar:4.2.2 in the shaded jar.
[INFO] Including net.java.dev.jna:jna:jar:4.2.2 in the shaded jar.

This same jar has been run successfully on large number of machines across a range of OSes and just this one machine has had this issue. Anything else I should look at to track this down?