-3

Possible Duplicate:
How do I programmatically determine operating system in Java?

in Java, how do I get what OS type (Mac, Windows, Linux, etc) that my java applet is being run in?

Thanks in advance ;D

Community
  • 1
  • 1
Hoolean
  • 31
  • 5

3 Answers3

3

The system property os.name provides the name of the operating system.

hmjd
  • 120,187
  • 20
  • 207
  • 252
2
public class OpertingSystemInfo 
{
  public static void main(String[] args)
  {
    String nameOS = "os.name";  
    String versionOS = "os.version";  
    String architectureOS = "os.arch";

    System.out.println("\n  The information about OS");
    System.out.println("\nName of the OS: " + System.getProperty(nameOS));
    System.out.println("Version of the OS: " + System.getProperty(versionOS));
    System.out.println("Architecture of THe OS: " + System.getProperty(architectureOS));
  }
}

http://www.roseindia.net/java/beginners/OSInformation.shtml

Michael Bisbjerg
  • 905
  • 10
  • 18
1
System.out.println(System.getProperties().get("os.name"));
Victor Sorokin
  • 11,878
  • 2
  • 35
  • 51