false, "message" => "CSRF token mismatch", "csrf" => csrf_token(), ]); exit; } if (($_POST["permalink"] ?? "") === "1") { echo json_encode([ "ok" => true, "data" => base64_encode(gzdeflate($code, 9, ZLIB_ENCODING_RAW)), ]); exit; } $id = getid(); $runnerDir = __DIR__ . "/../_runners/$id"; $srcDir = $runnerDir . "/src"; mkdir($srcDir, recursive: true); file_put_contents($srcDir . "/Program.java", $code); $isInDocker = getenv("IS_IN_DOCKER") === "1"; if ($isInDocker) file_put_contents("php://stderr", "[debug] In Docker\n"); chdir(__DIR__ . "/.."); $stderrFile = sys_get_temp_dir() . "/tmp{$id}.2"; exec( ($isInDocker ? "su-exec root " : "") . "./compile-and-run.sh '$id' Program 2>'$stderrFile'", $resultStr, $code); $resultStr = implode("\n", $resultStr); if (is_file($stderrFile)) { $stderrContents = file_get_contents($stderrFile); unlink($stderrFile); if (!empty($stderrContents)) { file_put_contents("php://stderr", "compile-and-run.sh failed: $stderrContents\n"); if ($code != 0) { echo json_encode([ "ok" => false, "message" => "Execution failed:\n$stderrContents", "csrf" => csrf_token(), ]); delTree($runnerDir); exit; } } } chdir(__DIR__); file_put_contents("php://stderr", "result: $result\n"); $csrf = csrf_token(); $result = [ "compile" => [ "status" => get($id, "c.s"), "stdout" => get($id, "c.0"), "stderr" => get($id, "c.1"), ], "run" => [ "status" => get($id, "r.s"), "stdout" => get($id, "r.0"), "stderr" => get($id, "r.1"), ], "runner" => $id, "ok" => true, "csrf" => $csrf, ]; if ($isInDocker) exec("su-exec root rm -rf '$runnerDir'"); else delTree($runnerDir); echo json_encode($result); exit; } $csrf = csrf_token(); ?> Java ">

☕️ Java Compiler

Powered by Eclipse Temurin 23.

Limitations: Compilation and execution time is limited to 30 seconds each. Your program won't have any network access and RAM is limited to 32 MiB. Source code size is limited to 16 KiB. Files will not be persisted between executions. Your program's main method needs to be contained inside a class named Program, as the code gets written to a file named Program.java.