I need to detect client side OS version and whether it's 32 bit/64 bit (Windows XP (32-bit) / Mac OS X 10.3.x / Linux OpenSUSE 11.2 etc.) using Applet. I will have to load the applet automatically when the JSP will be loaded and it will show all the correct information regarding user's OS. Please help me.
2 Answers 2
You can use java.lang.System to get basic information about the system your code is running on. Not sure if you want something more detailed than that.
System.out.println(System.getProperty("os.name"));
System.out.println(System.getProperty("os.arch"));
System.out.println(System.getProperty("os.version"));
Properties available via java.lang.System.getProperties() are listed here.
Edit:
The system properties for os.name, os.arch and os.version are not garaunteed to give you useful information. It depends highly on the platform and JVM you are using. If you want an analogy you can think of it as being roughly as useful as the user agent property property sent in HTTP requests (so, barely useful). There are some third party tools you can use for getting better system information, but you will have to sign your applet in order to get them to work, as they require permissions on the system that fall outside the Applet Security Sandbox. For example, SIGAR by HyperInc which was mentioned on this SO post.
Finally, to get your Applet to load on your page you need to include it on the page using applet tags. Heres an example:
Some more examples of applet tags are shown on Oracle's site.
Hope this helps.
4 Comments
You'll probably have as much luck parsing the User-Agent http header. You can either pass them to the applet using JavaScript or have the applet directly read them.