How to get OS name in Java?

System.getProperty("os.name") return the Operating System name in java.

Example

package com.pretech;
public class OSNameExample {
	public static void main(String[] args) {
		System.out.println(System.getProperty("os.name"));
	}
}

Output



Windows 7


No comments:

Post a Comment

12 classic String-based Java interview questions with simple explanations and code.

  1️⃣ Check if a String is a Palindrome Problem Given a string, check if it reads the same forward and backward. Example: "madam...

Featured Posts