{"record":{"id":"d677ea3abb0b3c9d","repo":"slint-ui/slint","slug":"could-not-generate-the-java-compiler-command-e","errorCode":null,"errorMessage":"Could not generate the java compiler command: {e}","messagePattern":"Could not generate the java compiler command: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backends/android-activity/build.rs","lineNumber":49,"sourceCode":"    std::fs::create_dir_all(&out_class_dir)\n        .unwrap_or_else(|e| panic!(\"Cannot create output directory {out_class_dir:?} - {e}\"));\n\n    let android_jar = android_build::android_jar(None).expect(\"No Android platforms found\");\n\n    // Compile the Java file into .class files\n    let o = JavaBuild::new()\n        .file(&java_src_path)\n        .class_path(&android_jar)\n        .classes_out_dir(&out_class_dir)\n        .java_source_version(8)\n        .java_target_version(8)\n        .debug_info(android_build::DebugInfo {\n            line_numbers: !release_mode,\n            variables: !release_mode,\n            source_files: !release_mode,\n        })\n        .command()\n        .unwrap_or_else(|e| panic!(\"Could not generate the java compiler command: {e}\"))\n        .args([\"-encoding\", \"UTF-8\"])\n        .output()\n        .unwrap_or_else(|e| panic!(\"Could not run the java compiler: {e}\"));\n\n    if !o.status.success() {\n        panic!(\"Java compilation failed: {}\", String::from_utf8_lossy(&o.stderr));\n    }\n\n    let o = Dexer::new()\n        .android_jar(&android_jar)\n        .class_path(&out_class_dir)\n        .collect_classes(&out_class_dir)\n        .unwrap()\n        .release(release_mode)\n        .android_min_api(20) // disable multidex for single dex file output\n        .out_dir(out_dir)\n        .command()\n        .unwrap_or_else(|e| panic!(\"Could not generate the D8 command: {e}\"))","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/backends/android-activity/build.rs#L31-L67","documentation":"The android-activity build script builds a javac command via the android-build helper and fails when `JavaBuild::command()` cannot construct the compiler invocation — typically because a JDK/javac toolchain cannot be located or configured. The build aborts before even attempting compilation.","triggerScenarios":"`JavaBuild::new()...command()` returns Err — no JAVA_HOME / JDK found, javac missing from PATH resolution, or invalid configuration passed to JavaBuild.","commonSituations":"Docker/CI images without a JDK installed; JAVA_HOME pointing at a JRE (no javac); broken Android SDK/NDK setup altering tool discovery.","solutions":["Install a full JDK (not a JRE) so javac exists (e.g. apt install openjdk-17-jdk or sdkman)","Set JAVA_HOME to the JDK root and ensure it's exported in the build environment","Verify `javac -version` works in the shell running cargo","Check the android SDK/platform setup (android_jar lookup precedes this) matches requirements"],"exampleFix":"// before\nexport JAVA_HOME=/usr/lib/jvm/java-17-jre\n// after\nexport JAVA_HOME=/usr/lib/jvm/java-17-jdk\nexport PATH=\"$JAVA_HOME/bin:$PATH\"","handlingStrategy":"validation","validationCode":"import shutil, os\nassert shutil.which(\"javac\"), \"javac not found; install a JDK\"\nassert \"jdk\" in os.environ.get(\"JAVA_HOME\", \"\").lower() or os.path.exists(os.path.join(os.environ.get(\"JAVA_HOME\", \"\"), \"bin\", \"javac\")), \"JAVA_HOME must point to a JDK\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install a JDK, not just a JRE, in build images","Export JAVA_HOME consistently in CI and locally","Verify toolchain setup with `javac -version` before building"],"tags":["android","java","build-script","toolchain"],"backgroundTag":"command-not-found","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}