This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Java doesn't give you all system properties
Posted by Kishori Sharan on November 02, 2000 at 10:03 AM
Hi Anuj Run Test.java attached file to get some of the things you wanted. I have sent you a DLL and .java file using which you can get other things like Drive Label, Disk free space etc. Thanx Kishori /////////////////Test.java import java.io.* ; import java.net.* ;
public class Test { public static void main ( String[] args ) { // To get all drives on your computer File f[] = File.listRoots ( ) ; for ( int i = 0 ; i < f.length ; i++ ) { System.out.println ( f[i] ) ; } // To get labels of drives and file system /* You can't get it just using java. Write your own platform specific program I have sent you the DLL which uses JNI to get all these things on windows */ // To get Free system memory only. However, to get free disk space, call // the native method in DLL long freeMemory = Runtime.getRuntime().freeMemory ( ) ; System.out.println ( " Free Memory:" + freeMemory ) ; //To get the computer name try { String computerName = InetAddress.getLocalHost( ).getHostName ( ) ; System.out.println ( "Computer Name: " + computerName ) ; } catch ( Exception e ) { System.out.println ( " Cannot get computer name" ) ; } } }
Replies:
|