Hardware Detection
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Tom_Carter
Posted On:   Wednesday, May 30, 2001 01:07 AM

Is it possible for me writing Java programs detecting my cpu type, memory storage, graphic adaptor and network connections?

Re: Hardware Detection

Posted By:   Luigi_Viggiano  
Posted On:   Friday, June 1, 2001 03:17 AM

It would be nice :) in this way we could be able to get hardware information about any platform... But... as hardare is platform dependent, Java isn't the best choice for your application. If you want to do it in Java, you should use JNI and link your code with native C procedures.


Anyway, for cpu type, memory storage should be not a problem... for network/graphic adapter it could be.

Try this code:


Properties p = System.getProperties();
System.out.println("CPU: "+p.getProperty("sun.cpu.isalist"));
System.out.println("OS: " + p.getProperty("os.name") + " "
+ p.getProperty("os.version"));

Runtime runtime = Runtime.getRuntime();
System.out.println("Total Memory: " + runtime.totalMemory());
System.out.println("Free Memory: " + runtime.freeMemory());

this works with JDK 1.3 by Sun and prints:

CPU: pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386
OS: Windows NT 4.0
Total Memory: 2031616
Free Memory: 1859192
About | Sitemap | Contact