Created
August 7, 2014 18:46
-
-
Save kodiyan/f86aba8dd577d469bcd2 to your computer and use it in GitHub Desktop.
Detect Operating System using Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String OSDetector () { | |
String os = System.getProperty("os.name").toLowerCase(); | |
if (os.contains("win")) { | |
return "Windows"; | |
} else if (os.contains("nux") || os.contains("nix")) { | |
return "Linux"; | |
}else if (os.contains("mac")) { | |
return "Mac"; | |
}else if (os.contains("sunos")) { | |
return "Solaris"; | |
}else { | |
return "Unkonwn OS"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is to determine Operating System name using Java. This will return name of OS for MAC, Linux, Windows and Solaris.