Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Obtaining system information (RAM, disk space, etc)

 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know of an easy way to obtain basic system information via Java? I'm talking about things like amount of RAM, total and available disk space, processor type/speed, etc. Stuff that would be used in conjunction with bug reports.

I've basically been tasked with trying to include that info with our app's automated error reports, but it's one of those "only do it if it takes less than an hour" kinda things... so no JNI or anything like that. I'm looking through the API docs (e.g. at classes like System), but nothing's jumping out.

Thanks!
 
John Weir
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Learn by example.
Hi here is a solution for you'r problem.

But please be sure to visit:

http://java.sun.com/docs/books/tutorial/essential/system/properties.html



 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I keep forgetting about Runtime.

Thanks!
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be aware though that the memory referred to in those Runtime methods is the memory used by the JVM process. It's not the total memory available on the machine. I don't know of a way to get that in Java, other than to use either System.exec() or JNI to access some platform-specific code. As for the stuff you want on the filesystem - that's hard to get in Java too, unless you're willing to use the Java SE 6 beta, where they've finally added several useful new methods to java.io.File, including getTotalSpace().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic