Getting user system properties

I would like to track user system properties, whenever the game is throwing exception.
I can’t find any related API to get below properties:

  • free disk space
  • computer RAM (free memory, used memory, total memory)
  • graphics card
  • processor

Anyone know how to get it?
I’ve look at System.getProperty(), Runtime, and java.io.File API.

[quote]I would like to track user system properties, whenever the game is throwing exception.
I can’t find any related API to get below properties:

  • free disk space
  • computer RAM (free memory, used memory, total memory)
  • graphics card
  • processor

Anyone know how to get it?
I’ve look at System.getProperty(), Runtime, and java.io.File API.
[/quote]
that question belongs to ‘newless cluebies’, not Java2D…
anyway… you can’t have those information using the JDK. you need to have platform specific native binaries.

You need JNI to find any of this.
You can easily find out if there is at least xMB of free disk space — just create a temporary file and write xMB of random data to it! Note that the data must be reasonably random to avoid being hoodwinked by disk compression systems.

This one is critical to many java apps, and there is an RFE for it (along with other improvements to the File class). Go to the sun “bug parade”, get yourself a JDC ID (free registration) and vote for the RFE (or perhaps it’s a bug?). It’s in the top 25 IIRC…

IMHO this is one of the top 10 things that should have been fixed somewhere in java 1.1.x, but we’re still waiting for. (modulo implementation difficulty - I’m speaking from user perspective only; perhaps it’s practically much more difficult than it seems?)

Of course, you can get information on the java processes…

You can get graphics card adapter information using LWJGL.

Cas :slight_smile:

[quote]This one is critical to many java apps, and there is an RFE for it
[/quote]
It is probably now covered by the much delayed JSR-203.
http://jcp.org/en/jsr/detail?id=203
I can’t help thinking that JSR-203 is still too big and we might see more visible progress if it was split into say 3 parts.

[quote]You can get graphics card adapter information using LWJGL.

Cas :slight_smile:
[/quote]
or jogl.

Blimey, didn’t realise they’d added it to JOGL. What’s the API calls?

Cas :slight_smile:

Thanks everyone for the answer! But the answer still: the standard API can’t get that info right?
No problem though, the information I gather right now is already capable to see what’s the cause of the exception anyway.

Just in case anyone interested what I mean by showing the user system properties when exception occured, please try this game:
http://goldenstudios.uni.cc/products/games/bin/theruneofmetadion.jnlp

And press ‘Q’ while playing, to raise the dummy exception :slight_smile: and see how I manage the exception.

Also please try this game, I use Class.newInstance() in applet environment, I don’t know it will raise SecurityException or not.
http://goldenstudios.uni.cc/products/games/bin/puzzle.html

As far as computer RAM goes, perhaps my understanding is flawed, but isn’t the critical question how much RAM is allocated to the VM? Because if the VM runs out of memory it doesn’t really matter how much system RAM you have. You’d have to restart the VM to increase it’s system RAM allocation. And said VM RAM values can be obtained by


Runtime runtime = Runtime.getRuntime();
runtime.freeMemory();
runtime.totalMemory();
runtime.maxMemory();

And as far as Java2D graphics go, what other information do you need exactly other than available accelerated memory? I mean, I wouldn’t think you would want or need to enumerate the graphics card’s 3D capabilities just for Java2D. And graphics memory can be obtained through the GraphicsDevice which will also tell you available resolutions, number of monitors, and other information pertinent to 2D.


GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
gd.getAvailableAcceleratedMemory()

And for CPU information there are the system properties:
sun.cpu.endian=little
sun.io.unicode.encoding=UnicodeLittle
sun.cpu.isalist=pentium i486 i386

Anyway, I know it’s not alot of information but maybe some very basic information is all he really needs for now?