In this post, we will see how to detect OS which you are using. You can use System.getProperty(“os.name”) to get current OS name. Sometimes , we need to write logic based on OS, so we get use this logic to detect current OS.
I am using Mac os to run above program. When I ran above program, I got below output
Java Program:
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.