{"record":{"id":"593c9d9fb59ed709","repo":"quarkusio/quarkus","slug":"printing-is-not-supported-with-quarkus-awt-extensi","errorCode":null,"errorMessage":"Printing is not supported with Quarkus AWT extension.","messagePattern":"Printing is not supported with Quarkus AWT extension\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions/awt/runtime/src/main/java/io/quarkus/awt/runtime/JDKSubstitutions.java","lineNumber":160,"sourceCode":"                        \"filename.Wingdings=WINGDING.TTF\\n\";\n                Files.writeString(configFile, minimalConfig, StandardCharsets.UTF_8);\n            }\n        } catch (IOException e) {\n            throw new UncheckedIOException(\"Failed to write Windows \" + configFile.toAbsolutePath(), e);\n        }\n    }\n}\n\n/**\n * Cut the dependency on Swing and Printing - we support server side, headless mode.\n * TODO: If an extension in Quarkiverse complains, we revisit it here.\n */\n@TargetClass(className = \"sun.awt.windows.WToolkit\", onlyWith = IsWindows.class)\nfinal class Target_sun_awt_windows_WToolkit {\n\n    @Substitute\n    public PrintJob getPrintJob(Frame frame, String jobtitle, Properties props) {\n        throw new UnsupportedOperationException(\"Printing is not supported with Quarkus AWT extension.\");\n    }\n\n    @Substitute\n    public PrintJob getPrintJob(Frame frame, String jobtitle, JobAttributes jobAttributes, PageAttributes pageAttributes) {\n        throw new UnsupportedOperationException(\"Printing is not supported with Quarkus AWT extension.\");\n    }\n}\n\n/**\n * Cut ties to windowing, desktop\n * TODO: If an extension in Quarkiverse complains, we revisit it here.\n */\n@TargetClass(className = \"sun.awt.windows.WObjectPeer\", onlyWith = IsWindows.class)\nfinal class Target_sun_awt_windows_WObjectPeer {\n    @Substitute\n    private static void initIDs() {\n        // no-op, no pData, destroyed, target\n    }","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/awt/runtime/src/main/java/io/quarkus/awt/runtime/JDKSubstitutions.java#L142-L178","documentation":"The Quarkus AWT extension supports only server-side, headless mode and explicitly cuts the dependency on printing. It substitutes sun.awt.windows.WToolkit.getPrintJob to throw UnsupportedOperationException whenever printing is attempted. This is intentional: java.awt.PrintJob is not available in Quarkus apps using the AWT extension.","triggerScenarios":"Calling Toolkit.getDefaultToolkit().getPrintJob(frame, jobtitle, props) on a Windows JVM/native-image with the Quarkus AWT extension present — the substituted method always throws.","commonSituations":"A library that lazily resolves a PrintJob (some imaging/reporting libs probe printing); migrating a Swing app snippet into a Quarkus service; Windows-specific toolkit substitution triggering print code paths.","solutions":["Remove or avoid the code path calling getPrintJob; render to images/streams instead","Configure the offending library to a non-printing (image/stream) output mode","Exclude printing-related dependencies that probe AWT printing at runtime"],"exampleFix":"// before\nPrintJob job = Toolkit.getDefaultToolkit().getPrintJob(frame, \"doc\", props);\n// after: render headlessly instead\nBufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);\nGraphics2D g = img.createGraphics();\ncomponent.paint(g);","handlingStrategy":"validation","validationCode":"if (Toolkit.getDefaultToolkit() instanceof sun.awt.windows.WToolkit) {\n  throw new IllegalStateException(\"Printing is unsupported under Quarkus AWT extension\");\n}","typeGuard":"static boolean printingSupported(GraphicsEnvironment env) {\n  return !env.isHeadless(); // in Quarkus AWT it is always headless; treat printing as unsupported\n}","tryCatchPattern":null,"preventionTips":["Never call Toolkit.getPrintJob in Quarkus AWT applications","Render to images or PDF streams instead of using AWT printing","Audit third-party imaging libraries for hidden print code paths"],"tags":["awt","printing","unsupported-operation","windows"],"backgroundTag":"printing-not-supported","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}