I want to convert this sample of Java code to jython code
import java.lang.management.ManagementFactory;
public class GetSpecifications {
public static void main(String[] args){
long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean())
.getTotalPhysicalMemorySize(); //casting
System.out.println(memorySize);
}
}
In Jython, casts are unnecessary because the language automatically looks up methods as needed.
Therefore, your code would simply be
from java.lang.management import ManagementFactory
print ManagementFactory.getOperatingSystemMXBean().getTotalPhysicalMemorySize()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.