2014-05-13 10 views
-4

Java를 사용하여 컴퓨터의 하드웨어 사양을 감지하는 방법이 있습니까?Java로 시스템 사양 검색

예 : CPU, RAM, VGA, PCI 장치는,

디스크

당신의 시선 난 당신이 자바의 Runtime 클래스 (I 추측 5)를 사용할 필요가 있다고 생각이 들어

+0

다음 번에 질문 제목을 google first에 입력하십시오. – csmckelvey

답변

0

. Runtime 클래스뿐만 아니라. 거즈의

목록 :

나는이 어딘가에 주위에 거짓말을했다.

public static void main(String[] args) { 

    long kilobytes = 1024; 
    long megabytes = kilobytes * 1024; 
    long gigabytes = megabytes * 1024; 

    String nameOS = "os.name"; 
    String versionOS = "os.version"; 
    String architectureOS = "os.arch"; 
    System.out.println("\n Info about OS"); 
    System.out.println("\nName of the OS: " + 
    System.getProperty(nameOS)); 
    System.out.println("Version of the OS: " + 
    System.getProperty(versionOS)); 
    System.out.println("Architecture of The OS: " + 
    System.getProperty(architectureOS)); 
    Map<String, String> env = System.getenv(); 
    System.out.println("Environment values"); 
    for(String key : env.keySet()) { 
     System.out.println("K: " + key + " \n\tV: " + env.get(key)); 
    } 
    /* Total number of processors or cores available to the JVM */ 
    System.out.println("\nAvailable processors (cores): " + 
     Runtime.getRuntime().availableProcessors()); 

    /* Total amount of free memory available to the JVM */ 
    System.out.println("Free memory (megabytes): " + 
     Runtime.getRuntime().freeMemory()/(float) megabytes); 

    /* This will return Long.MAX_VALUE if there is no preset limit */ 
    long maxMemory = Runtime.getRuntime().maxMemory(); 
    /* Maximum amount of memory the JVM will attempt to use */ 
    System.out.println("Maximum memory (megabytes): " + 
     (maxMemory == Long.MAX_VALUE ? "no limit" : maxMemory/(float) megabytes)); 

    /* Total memory currently available to the JVM */ 
    System.out.println("Total memory available to JVM (megabytes): " + 
     Runtime.getRuntime().totalMemory()/(float) megabytes); 

    /* Get a list of all filesystem roots on this system */ 
    File[] roots = File.listRoots(); 

    /* For each filesystem root, print some info */ 
    for (File root : roots) { 
     System.out.println("\nFile system root: " + root.getAbsolutePath()); 
     System.out.println("Total space (gigabytes): " + (root.getTotalSpace()/(float) gigabytes)); 
     System.out.println("Free space (gigabytes): " + (root.getFreeSpace()/(float) gigabytes)); 
     System.out.println("Usable space (gigabytes): " + (root.getUsableSpace()/(float) gigabytes)); 

    } 
    System.out.println("\n\nProperties:\n------\n"); 
    System.getProperties().list(System.out); 
    } 
    } 
+0

감사합니다. 매우 도움이됩니다. – Klisman