• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

OperatingSystemMXBean.getTotalPhysicalMemorySize()

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this code will returns the total amount of physical memory in bytes.

OperatingSystemMXBean.getTotalPhysicalMemorySize()

why when i write that code it says that the method is undefined? i thought that code is already in the OperatingSystemMXBean interface.
im using eclipse
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see a method getTotalPhysicalMemorySize() in the API documentation of interface OperatingSystemMXBean. Where did you find this method?
 
Sara Brown
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
at Here

Besides, ive been reading to other forum as well and most of them stated just by
OperatingSystemMXBean.getTotalPhysicalMemorySize();

Even when you look at the url given, it also stated that way.

if we actually need to make the getTotalPhysicalMemorySize method, then how should we do? Please i really need to read the physical memory size in my coding for my assignment. thank you.

*it is solo assignment where each of us have different topic to make
 
Bartender
Posts: 10759
68
Hibernate Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sara Brown wrote:Besides, ive been reading to other forum as well and most of them stated just by
OperatingSystemMXBean.getTotalPhysicalMemorySize();
...if we actually need to make the getTotalPhysicalMemorySize method, then how should we do?


Well, one thing I notice is that the two interfaces are not the same: one is java.lang.management.OperatingSystemMXBean, the other is com.sun.management.OperatingSystemMXBean which is an extension of the first. Are you sure you've imported the correct one?

From what I can see, it doesn't apply to Unix OS's either (see UnixOperatingSystemMXBean). [Edit: apologies; that's wrong. The Unix... class is an extension of the second one]

Winston
 
Sara Brown
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Winston,

im using import java.lang.management.OperatingSystemMXBean

this is the correct way to import, right? and the extension you mentioned before, may i know how?
 
Sara Brown
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
by the way, someone had suggested to use OperatingSystemMXBean operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
and import com.sun.management.OperatingSystemMXBean

but then it shows access restriction due to restriction on required library. what should i do?
 
Marshal
Posts: 64618
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sara Brown wrote:Hi Winston,

im using import java.lang.management.OperatingSystemMXBean

this is the correct way to import, right? . . .

Assuming your version in the code ends with a ; yes. How are you calling it? How did you get an object which implements that interface? As Jeff has already said, that interface doesn’t have that method.
Beware of using packages beginning in com. They are not intended for general use, and may be removed in a future version or update of Java™. Try going to the API documentation and clicking index→G→ctrl-F-getTotalPhysicalMemorySize, and see whether you find the same as I did: nothing.
 
Winston Gutkowski
Bartender
Posts: 10759
68
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sara Brown wrote:im using import java.lang.management.OperatingSystemMXBean
this is the correct way to import, right?


It's the correct way to import, but the wrong interface. The one you're importing doesn't include your required method.

As for getting the right one: you may have to download a jar for com.sun.management (or include it in your load path). I honestly don't know where you'd find it though, because I've never used it.

Winston

PS: This link might help.
 
Sara Brown
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have been trying to fix the code and i realize that when im using eclipse indigo, it have errors but then when im trying to do the same thing in eclipse europa, it works well.

im using

and import


and put it inside the try and catch and it works perfectly well. how is that happen? its amazing. im feeling sunshine. but seriously how does do the same thing in eclipse indigo gets an error?

*anyway thanks for the link given. im trying to look at it.
 
Sara Brown
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
im sorry..im not importing anything..i just the code above. it that the right way?
 
Winston Gutkowski
Bartender
Posts: 10759
68
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sara Brown wrote:but seriously how does do the same thing in eclipse indigo gets an error?


Probably because europa included the relevant jar by default and indigo doesn't (I'm assuming Indigo is newer, 'cause it ain't a moon of Jupiter).

Winston
 
Screaming fools! It's nothing more than a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!