Question

How to determin the underlying OS, jython is running on. Not 'java', but 'nt' or 'posix'.

  • platform.platform
  • os.name
  • and sys.platform only return 'java'
Was it helpful?

Solution

For jython I use java.lang.System.getProperty("os.name"):

import sys

def get_os_version():
    ver = sys.platform.lower()
    if ver.startswith('java'):
        import java.lang
        ver = java.lang.System.getProperty("os.name").lower()
    return ver

print(get_os_version())
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top