I have this code to read physical memory:
com.sun.management.OperatingSystemMXBean os = (com.sun.management.OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
long physicalMemorySize =os.getTotalPhysicalMemorySize();
System.out.println("physicalMemorySize="+physicalMemorySize);
I have JDK 1.8.0_121 (64bit, on Windows)
This code is compiled without problem, and I can run it in console application, it runs OK.
But when I put this code to some Bean or JSP page on WildFly 10 server, it shows error:
Caused by: java.lang.ClassNotFoundException: com.sun.management.OperatingSystemMXBean
WildFly uses exactly the same JDK, so it should see this class like console application sees it.
That class is in jdk1.8.0_121\jre\lib\rt.jar
so I do not understand why WildFly complains about that ClassNotFoundException.
What's the problem? How to make WildFly run that code?