3

Is there any way I can get system info, like processor/ram etc (preferably cross platform, in browser)?

I am looking to implement this in a website, so I need it in either flash or a java applet.

Anant
  • 601
  • 2
  • 6
  • 14

4 Answers4

2

You can use SIGAR. http://support.hyperic.com/display/SIGAR/Home

Note that it is licensed under GPL. It may not suit you unless you are using it for an internal application or for an open-source application.

Chandra Sekar
  • 10,683
  • 3
  • 39
  • 54
  • Thanks for the reply Chandru, but I was looking for some applet I could use on my site. – Anant Mar 03 '10 at 17:11
  • 1
    You can use this to make your own applet,this is an API – Mahmoud Hanafy Mar 15 '10 at 19:51
  • This library cannot be used in an Applet due to reliance on native libraries compiled for each architecture. – tovare Mar 19 '10 at 19:56
  • 1
    It is possible to use it if you use JNLP for your applets. https://applet-launcher.dev.java.net/ is a good project for enabling it on older JREs. – Chandra Sekar Mar 22 '10 at 05:32
  • Thanks, but that wouldn't that process is more like installing an application, in the sense of requiring user permission etc. and some cross-platform/cross-JVM reliability wooes to boot. – tovare Mar 23 '10 at 01:22
  • Yes it does require your applet to be signed which in turn would lead to a permission prompt. However, if the native libs and its Java API work well across platforms, cross-platform functioning is pretty much guaranteed. A good example if this case is JOGL and Java 3D. – Chandra Sekar Mar 23 '10 at 05:24
2

Try this applet program.

import com.sun.servicetag.SystemEnvironment;
import java.lang.management.ManagementFactory;
public class Config extends java.applet.Applet{
   public void paint(java.awt.Graphics g){
        g.drawString("Hi.. This is Venkatesh..",50,10);
        SystemEnvironment se = SystemEnvironment.getSystemEnvironment();
        g.drawString("CpuManufacturer:"+se.getCpuManufacturer(),50,40);
        g.drawString("HostID:"+se.getHostId(),50,60);
        g.drawString("Host Name:"+se.getHostname(),50,80);
        g.drawString("OS Architecture:"+se.getOsArchitecture(),50,100);
        g.drawString("OS Name:"+se.getOsName(),50,120);
        g.drawString("OS Verstion:"+se.getOsVersion(),50,140);
        g.drawString("Serial no:"+se.getSerialNumber(),50,160);
        g.drawString("System model:"+se.getSystemModel(),50,180);
        g.drawString("System Manufacturer:"+se.getSystemManufacturer(),50,200);
        com.sun.management.OperatingSystemMXBean mxbean = (com.sun.management.OperatingSystemMXBean)ManagementFactory.getOperatingSystemMXBean();
        g.drawString("Available Processors:"+mxbean.getAvailableProcessors(),50,220);
 g.drawString("TotalRAM:"+mxbean.getTotalSwapSpaceSize()/(1024*1024*1024)+""+"GB",50,240);
  g.drawString("RAM SIZE :" + (mxbean.getTotalPhysicalMemorySize()/(1024*1024*1024))+ " GB ",50,260);
    }
}


<Applet Code="HelloWorld.class" width="150" height="150">
</Applet>
Stephen Denne
  • 36,219
  • 10
  • 45
  • 60
Venkat
  • 20,802
  • 26
  • 75
  • 84
  • This solution might only work using Sun JDK because com.sun classes are not part of the Java standard. You can't drop a jar in the deployment either because the implementation of SystemEnviroment is not pure Java, so you have implementations such as LinusSystemEnviroment and WindowsSystemEnviroment behind that class. – tovare Mar 19 '10 at 20:32
1

For RAM info take a look at this thread -> so use the java.lang.managament package or take a look at this or that answer.

To get some other RAM info do:

Runtime.getRuntime().availableProcessors()
Runtime.getRuntime().maxMemory();

Or to get info about OS etc try:

System.getProperties().list(System.out);

SIGAR seems to be the only out-of-the-box library for this task.

Community
  • 1
  • 1
Karussell
  • 17,085
  • 16
  • 97
  • 197
1

'Hi,

Java i think is the more restrictive option of the two, in terms of what you can pull from the client.

Flash will give you some information through the Capabilities class, it has somewhat looser security than Java so I think it's your best bet.

package {
    import flash.display.Sprite;
    import flash.system.Capabilities;

    public class CapabilitiesExample extends Sprite {
        public function CapabilitiesExample() {
            showCapabilities();
        }

        private function showCapabilities():void {
            trace("avHardwareDisable: " + Capabilities.avHardwareDisable);
            trace("hasAccessibility: " + Capabilities.hasAccessibility);
            trace("hasAudio: " + Capabilities.hasAudio);
            trace("hasAudioEncoder: " + Capabilities.hasAudioEncoder);
            trace("hasEmbeddedVideo: " + Capabilities.hasEmbeddedVideo);
            trace("hasMP3: " + Capabilities.hasMP3);
            trace("hasPrinting: " + Capabilities.hasPrinting);
            trace("hasScreenBroadcast: " + Capabilities.hasScreenBroadcast);
            trace("hasScreenPlayback: " + Capabilities.hasScreenPlayback);
            trace("hasStreamingAudio: " + Capabilities.hasStreamingAudio);
            trace("hasVideoEncoder: " + Capabilities.hasVideoEncoder);
            trace("isDebugger: " + Capabilities.isDebugger);
            trace("language: " + Capabilities.language);
            trace("localFileReadDisable: " + Capabilities.localFileReadDisable);
            trace("manufacturer: " + Capabilities.manufacturer);
            trace("os: " + Capabilities.os);
            trace("pixelAspectRatio: " + Capabilities.pixelAspectRatio);
            trace("playerType: " + Capabilities.playerType);
            trace("screenColor: " + Capabilities.screenColor);
            trace("screenDPI: " + Capabilities.screenDPI);
            trace("screenResolutionX: " + Capabilities.screenResolutionX);
            trace("screenResolutionY: " + Capabilities.screenResolutionY);
            trace("serverString: " + Capabilities.serverString);
            trace("version: " + Capabilities.version);
        }
    }
}

Example from: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/

In order to detect speed you need to do benchmarking.

Tips: By monitoring for instance rendering/calculation time in javascript, flash or java you can dynamically alter the behaviour of your application based on real-world performance, instead of running a benchmark prior to launching the application (as I have seen others do). For instance: Thread 1: Monitor and alter data (for instance rotation degree in a rotating cube). Thread 2: Do the heavy calculation and rendering.

(This is easy in Java with threads, but in flash you need to chunk your processing and have the heavy code check with the monitor on how to proceed).

Tips 2: There are lot's of public benchmarks, so you could narrow down what kind of CPU people are running by running a benchmark and compare with a benchmark results-database.

Hope this helps !

Cheers

tovare
  • 4,027
  • 5
  • 29
  • 30