There's a couple of memory-related methods in the Runtime class, but note that they only give information about the amount of memory available to (or used by) the JVM, not the hardware it runs on.
Generally, Java is the wrong language to do this kind of thing, since it requires access to OS APIs that Java does not provide.
Most of the information you need will be contained in the Runtime class. Have a look at the link. It should be straightforward. If you run into problems with it, I will try to help you out further.
发布评论
评论(2)
中有一些与内存相关的方法Runtime
类,但请注意,它们仅提供有关 JVM 可用(或使用)的内存量的信息,而不提供其运行的硬件的信息。一般来说,Java 是不适合做这种事情的语言,因为它需要访问 Java 不提供的操作系统 API。
There's a couple of memory-related methods in the
Runtime
class, but note that they only give information about the amount of memory available to (or used by) the JVM, not the hardware it runs on.Generally, Java is the wrong language to do this kind of thing, since it requires access to OS APIs that Java does not provide.
您需要的大部分信息将包含在 运行时类。看看链接。它应该很简单。如果您遇到问题,我会尽力进一步帮助您。
Most of the information you need will be contained in the Runtime class. Have a look at the link. It should be straightforward. If you run into problems with it, I will try to help you out further.