title: How many hardware details can a Java Applet Discover?
body: <p>I'm writing a Java applet to run differently under different hardware. For instance if I know a computer has a large amount of RAM but a weak processor, I can alter the balance of some time-memory trade-offs. Being able to discover the exact make and model of the CPU on which the applet is running could be helpful. Having such information would allow me to benchmark my software against different systems and find bottlenecks.</p>
  
  <p>Generally what I'm looking for is:</p>
  
  <ul>
  <li>Number of cores and/or processors</li>
  <li>32 bit vs 64 bit CPU</li>
  <li>CPU Cache line size </li>
  <li>Size of L1, L2, L3 cache</li>
  <li>Set associativity of cache</li>
  <li>Size of TLB</li>
  <li>Exact Make/Model information on the CPU</li>
  <li>FSB information</li>
  <li>Amount of RAM</li>
  <li>Amount of swap/virtual memory</li>
  <li>The JVM in which the applet is being run</li>
  <li>Operating System running JVM</li>
  <li>System Load</li>
  <li>Number of used/unused Kernal threads</li>
  <li>Bandwidth of internet connection</li>
  <li>Memory available</li>
  <li>Graphics cards in use</li>
  <li>If Operating System is being visualised</li>
  <li>Network resource in use</li>
  </ul>
  
  <p>Is any of this information baked into Java Applets. Are there libraries for finding any of this information? Applet benchmarking tools to discover/guess some of it? Any clever tricks you can think of?</p>
  
  <p>Are their any aspects of computer hardware which are blocking. That is, could a Java applet detect that something is in use or unavailable by trying to access it and being denied (maybe a particular TCP port or graphics accelerator).</p>
  
  <p>Disclaimer: I know that caring about the hardware goes against the Java ideology of not caring about the hardware. While comments point this out may be helpful for other readers that see this question, please note that such answers are not what I am looking for.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Added additional information:</p>
  
  <p><strong>java.lang.<a href="http://java.sun.com/javase/6/docs/api/java/lang/management/package-summary.html" rel="nofollow noreferrer">management</a></strong> provides all sorts of information on the system which the JVM is running on.</p>
  
  <p><strong>java.lang.management.<a href="http://java.sun.com/javase/6/docs/api/java/lang/management/OperatingSystemMXBean.html" rel="nofollow noreferrer">OperatingSystemMXBean</a></strong> provides:</p>
  
  <ol>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/OperatingSystemMXBean.html#getAvailableProcessors()" rel="nofollow noreferrer">getAvailableProcessors()</a> The number of available processors equivalent <a href="http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html#availableProcessors()" rel="nofollow noreferrer">Runtime.availableProcessors()</a></li>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/OperatingSystemMXBean.html#getSystemLoadAverage()" rel="nofollow noreferrer">getSystemLoadAverage()</a> The average load on the system the system load average for the last minute.</li>
  </ol>
  
  <p><strong>java.lang.management.<a href="http://java.sun.com/javase/6/docs/api/java/lang/management/ManagementFactory.html#getMemoryMXBean()" rel="nofollow noreferrer">ManagementFactory</a></strong></p>
  
  <ol>
  <li><p><strong><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/GarbageCollectorMXBean.html" rel="nofollow noreferrer">getGarbageCollectorMXBeans()</a></strong> returns a list ofGarbageCollectorMXBeans. Each   <a href="http://java.sun.com/javase/6/docs/api/java/lang/management/GarbageCollectorMXBean.html" rel="nofollow noreferrer">GarbageCollectorMXBean</a> can be queried for the following information:</p>
  
  <ol>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/GarbageCollectorMXBean.html#getCollectionCount()" rel="nofollow noreferrer">getCollectionCount()</a> number of gc which have occured using this
  bean.</li>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/GarbageCollectorMXBean.html#getCollectionTime()" rel="nofollow noreferrer">getCollectionTime()</a> approximate accumulated time elapsed
  between gc's in milliseconds. (Note:
  The Java virtual machine
  implementation may use a high
  resolution timer to measure the
  elapsed time.)</li>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/MemoryManagerMXBean.html#getName()" rel="nofollow noreferrer">getName()</a> the name of the memory manager.</li>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/MemoryManagerMXBean.html#getMemoryPoolNames()" rel="nofollow noreferrer">getMemoryPoolNames()</a> the memory pools that this gc manages.</li>
  </ol></li>
  <li><p><strong><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/ManagementFactory.html#getThreadMXBean()" rel="nofollow noreferrer">getThreadMXBean()</a></strong> returns the <a href="http://java.sun.com/javase/6/docs/api/java/lang/management/ThreadMXBean.html" rel="nofollow noreferrer">ThreadMXBean</a> which provides:</p>
  
  <ol>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/ThreadMXBean.html#getCurrentThreadCpuTime()" rel="nofollow noreferrer">getCurrentThreadCpuTime()</a> Returns the total CPU time for the current thread in nanoseconds. If the implementation distinguishes between user mode time and system mode time, the returned CPU time is the amount of time that the current thread has executed in user mode or system mode. </li>
  </ol></li>
  <li><strong><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/RuntimeMXBean.html" rel="nofollow noreferrer">getRuntimeMXBean</a></strong> returns <a href="http://java.sun.com/javase/6/docs/api/java/lang/management/RuntimeMXBean.html" rel="nofollow noreferrer">RuntimeMXBean</a>
  
  <ol>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/RuntimeMXBean.html#getStartTime()" rel="nofollow noreferrer">getUptime()</a> uptime of the Java virtual machine in milliseconds. </li>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/RuntimeMXBean.html#getStartTime()" rel="nofollow noreferrer">getStartTime()</a> start time of the Java virtual machine in milliseconds.</li>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/RuntimeMXBean.html#getInputArguments()" rel="nofollow noreferrer">getInputArguments()</a> Returns the input arguments passed to the Java virtual machine which does not include the arguments to the main method. </li>
  </ol></li>
  <li><strong><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/CompilationMXBean.html" rel="nofollow noreferrer">getCompilationMXBean</a></strong> returns the <a href="http://java.sun.com/javase/6/docs/api/java/lang/management/CompilationMXBean.html" rel="nofollow noreferrer">CompilationMXBean</a>
  
  <ol>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/CompilationMXBean.html#getName()" rel="nofollow noreferrer">getName()</a> the name of the JIT</li>
  <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/CompilationMXBean.html#getTotalCompilationTime()" rel="nofollow noreferrer">getTotalCompilationTime()</a> time in milliseconds it took to compile your code.</li>
  </ol></li>
  </ol>