for desktop:
java.lang.System.getProperty("os.name")
for web, you can check browser info in HTTP request, but information may not be available and it can be faked,
the best method here is to use a java applet (or script) to check system setting, and send it to server.