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
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.

- 1
- 1

- 79,279
- 19
- 185
- 195
-
Thank you perception for your reply...I did the same thing but it's not reliable...It's not always detecting the correct version and the bit information. It would be nice if you can tell me some other solution. And second thing can you tell me that how to load the applet on load time of body. Actually I have not worked with applet before. – Neel Jun 29 '11 at 18:55
-
@Neel, yes those system properties are very basic like I mentioned in my answer. I did some edit's since you need more specific information than what is easily available just using java.lang.System. I would recommend just getting your applet working first with the basic information, before incorporating any third party libraries and having to sign your jar. – Perception Jun 29 '11 at 19:17
-
@perception- I have tried SIGAR,it's fine.But it can't be used as I need the information about the client machine's OS means the remote OS as it is a web project. I would have done it using user agent but I have to use Applet and detect using java. – Neel Jun 29 '11 at 19:42
-
@Neel - whats the problem with bundling the SIGAR jar along with your applet code and running it on the client? I haven't used it personally but *theoretically* this should work. – Perception Jun 29 '11 at 19:52
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.

- 53,220
- 42
- 124
- 197