Java library to easily detect running Operating System, BSD Flavor, Linux Distribution, Desktop Environment and Architecture
MIT License
Java library to easily detect running Operating System, BSD Flavor, Linux Distribution, Desktop Environment and Architecture
AbstractOperatingSystem os = OperatingSystem.getOperatingSystem();
if (os.getType() == OperatingSystem.LINUX) {
LinuxOperatingSystem los = (LinuxOperatingSystem) os;
if (los.getDistro() == Distro.ELEMENTARY_OS) {
System.out.println("Is running eOS");
} else {
System.out.println("Is running " + los.getDisplayString());
}
}
AbstractOperatingSystem os = OperatingSystem.getOperatingSystem();
if (os.getType() == OperatingSystem.MACOS) {
MacOSOperatingSystem xos = (MacOSOperatingSystem) os;
if (xos.getVersion() == MacOSVersion.YOSEMITE) {
System.out.println("Is running Yosemite " + xos.getVersion().getVersion());
// Will print: Is running Yosemite 10.10
}
System.out.println(xos.getDisplayString());
// Will print (if running mavericks): Mac OS X Mavericks 10.9
}
if (os.getType() == OperatingSystem.LINUX) {
LinuxOperatingSystem los = (LinuxOperatingSystem) os;
System.out.println(los.getDisplayString());
// Will print (if running Kali): Kali Linux 1.0
if (los.getArch() == Arch.x86_64) {
System.out.println("Is 64 bit");
}
}
Note: These are the only ones I have tested with. Will work well on untested systems, but the checked ones are absolutely working. Linux distro and BSD flavor detection after 1.0 is based on screenFetch