How to get the current OS name and version in Scala

1 Answer

0 votes
object OSInfo {
  def main(args: Array[String]): Unit = {
    // Get the OS name
    val osName = System.getProperty("os.name")

    // Get the OS version
    val osVersion = System.getProperty("os.version")

    // Get the OS architecture
    val osArch = System.getProperty("os.arch")

    println(s"Operating System: $osName")
    println(s"Version: $osVersion")
    println(s"Architecture: $osArch")
  }
}

  
     
/*
run:
  
Operating System: Linux
Version: 5.15.0-122-generic
Architecture: amd64

*/

 



answered Mar 28, 2025 by avibootz

Related questions

1 answer 110 views
1 answer 116 views
1 answer 117 views
1 answer 125 views
1 answer 83 views
1 answer 111 views
3 answers 132 views
...