apache/hadoop · error · RuntimeException

Operating system {} not supported by this class

Error message

Operating system {} not supported by this class

What it means

hadoop-streaming's Environment class discovers how to dump environment variables by matching the os.name property: Windows uses 'cmd /C set', unix-likes (names containing ix/linux/freebsd/sunos/solaris/hp-ux) and macOS use 'env'. If os.name matches none of these, command stays null and the constructor throws RuntimeException 'Operating system <OS> not supported by this class'.

Source

Thrown at hadoop-tools/hadoop-streaming/src/main/java/org/apache/hadoop/streaming/Environment.java:61

    // environments that you expect to run in
    // http://lopica.sourceforge.net/os.html
    String command = null;
    String OS = System.getProperty("os.name");
    String lowerOs = StringUtils.toLowerCase(OS);
    if (OS.indexOf("Windows") > -1) {
      command = "cmd /C set";
    } else if (lowerOs.indexOf("ix") > -1 || lowerOs.indexOf("linux") > -1
               || lowerOs.indexOf("freebsd") > -1 || lowerOs.indexOf("sunos") > -1
               || lowerOs.indexOf("solaris") > -1 || lowerOs.indexOf("hp-ux") > -1) {
      command = "env";
    } else if (lowerOs.startsWith("mac os x") || lowerOs.startsWith("darwin")) {
      command = "env";
    } else {
      // Add others here
    }

    if (command == null) {
      throw new RuntimeException("Operating system " + OS + " not supported by this class");
    }

    // Read the environment variables

    Process pid = Runtime.getRuntime().exec(command);
    BufferedReader in = new BufferedReader(
        new InputStreamReader(pid.getInputStream(), StandardCharsets.UTF_8));
    try {
      while (true) {
        String line = in.readLine();
        if (line == null)
          break;
        int p = line.indexOf("=");
        if (p != -1) {
          String name = line.substring(0, p);
          String value = line.substring(p + 1);
          setProperty(name, value);
        }

View on GitHub (pinned to 2add963021)

Solutions

  1. Run the streaming job on a supported platform (Linux, macOS, Windows, Solaris/HP-UX/AIX-style unix)
  2. Avoid code paths that need Environment dumping: pass variables via job configuration (stream.addenvironment) instead of relying on inherited env detection
  3. Patch Environment.java locally to recognize the platform and contribute it upstream
  4. On the offending OS, run streaming under a compatibility layer (e.g. z/OS Unix System Services reporting a matched name)
Defensive patterns

Strategy: fallback

Validate before calling

// preflight: only use streaming's Environment on platforms it recognizes
String os = System.getProperty("os.name", "").toLowerCase(Locale.ROOT);
boolean supported = os.contains("windows") || os.contains("ix") || os.contains("linux")
    || os.contains("freebsd") || os.contains("sunos") || os.contains("solaris")
    || os.contains("hp-ux") || os.startsWith("mac os x") || os.startsWith("darwin");
if (!supported) { /* route around Environment */ }

Try / catch

try { env = new Environment(); } catch (RuntimeException e) { /* fall back to System.getenv() and pass needed vars explicitly via job config (stream.addenvironment) */ }

Prevention

When it happens

Trigger: Running a streaming job on the client/task side under an OS whose os.name isn't covered — e.g. z/OS, OpenVMS, OS/2, or an exotic JVM reporting an unexpected os.name — so Environment cannot choose a dump command and fails at construction.

Common situations: Legacy mainframes or niche platforms (z/OS) running the streaming client, JVMs/localized systems reporting unusual os.name values, or unit tests that manipulate os.name; commonly surfaces as an immediate RuntimeException during job setup rather than during data processing.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/f5cb78dafa851c8b. Report an issue: GitHub.