!7 sbool startWithNohup = true; sS mainClassName = "StefansOS"; static S v = "x30"; static S sourceID = #1001638; static S javaTarget = "1.6"; // compile JavaX for everyone static S ecjSnippetID = #1011501; // ecj.zip static S compilerBotID = #1001155; static int compressionLevel = 9; // Zip compression - highest level p { File jarFile = new File(programDir(), "Stefans OS.jar"); S s = getServerTranspiled(sourceID); S libs = firstLine(s); s = dropFirstLine(s); L tok = javaTok(s); javax_prepareX30SourceForDeployment(tok); jreplace(tok, "public class " + v, "class " + v); S src = join(tok); S mainCode; if (startWithNohup) mainCode = [[x30.nohupJavax("#1016005")]]; else mainCode = [[x30.main(new String[] {"#1016005"});]]; src += [[ public class ]] + mainClassName + [[ { public static void main(String[] args) { ]] + mainCode + [[ } } ]]; File javaFile = new File(programDir(), mainClassName + ".java"); saveTextFile(javaFile, src); print("ok, made " + javaFile.getAbsolutePath()); print("Now compiling."); S botQuestion = "Please compile this Java text: " + quote(src) + " for java version " + quote(javaTarget); print("Question to bot: " + shorten(botQuestion, 200)); Class compilerBot = hotwire(compilerBotID); S answer = cast call(compilerBot, "answer", botQuestion); print("Bot said: " + answer); if (answer == null) fail(); new Matches m; if (!match3("ok, *", answer, m)) if (match3("Compile error", answer)) fail("Compile Error."); else fail("I don't understand the bot, exiting"); S classesDir = unquote(m.m[0]); print("I think the classes dir is: " + classesDir); if (!new File(classesDir).isDirectory()) fail("huh?"); print("Now making jar."); File ecj = loadLibrary(ecjSnippetID); ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(jarFile)); zout.setLevel(compressionLevel); makeManifestWithMainClass(zout, mainClassName); dir2zip(classesDir, zout); zip2zip_exceptManifest(ecj, zout); zout.close(); makeExecutable(jarFile); print("ok, made " + jarFile.getAbsolutePath() + " (" + jarFile.length() + " bytes)"); }