GithubHelp home page GithubHelp logo

dalalsunil1986 / oslib Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wille/oslib

0.0 0.0 0.0 220 KB

Java library to easily detect running Operating System, BSD Flavor, Linux Distribution, Desktop Environment and Architecture

License: MIT License

Java 100.00%

oslib's Introduction

oslib

Java library to easily detect running Operating System, BSD Flavor, Linux Distribution, Desktop Environment and Architecture

Examples

Detecting if running Elementary OS (Linux)

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());
	}
}

Getting all information available about current OS

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");
	}
}

Current Known Compatibility:

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

  • macOS Mac OS X
  • Windows
  • Arch Linux
  • Amazon Linux
  • Fedora
  • Linux Mint
  • Ubuntu
  • Debian
  • CentOS
  • Crunchbang
  • Gentoo
  • Funtoo
  • FreeBSD
  • OpenBSD
  • NetBSD
  • DragonFlyBSD
  • OpenSUSE
  • Mandriva/Mandrake
  • Slackware
  • Red Hat (RHEL)
  • Frugalware
  • Peppermint
  • SolusOS
  • Mageia
  • ParabolaGNU/Linux-libre
  • Viperr
  • LinuxDeepin
  • Chakra
  • Trisquel
  • Manjaro
  • elementary OS
  • Scientific Linux
  • Kali Linux
  • Sabayon
  • NixOS
  • Crux
  • Lunar Linux
  • BLAG
  • gNewSense
  • Dragora
  • Chapeau
  • KDE neon
  • Oracle Linux
  • Qubes
  • Linux (If no distro detected or failed to detect)
  • Solaris

oslib's People

Contributors

wille avatar himanshub16 avatar tristan971 avatar lionzxy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.