How to detect OS in Java

This article shows a handy Java class that uses System.getProperty("os.name") to detect which type of operating system (OS) you are using now. 1. Detect OS (Original Version) This code can detect Windows, Mac, Unix, and Solaris. OSValidator.java package com.mkyong.system; public class OSValidator { private static String OS = System.getProperty("os.name").toLowerCase(); public static void main(String[] args) { …

Read more