static File javaCompileToJar_standard(S src, File destJar) { ret javaCompileToJar_standard(src, "", destJar); } // returns path to jar static synchronized File javaCompileToJar_standard(S src, S dehlibs, File destJar) { S javaTarget = null; // use default target print("Compiling " + l(src) + " chars"); S md5 = md5(src); File jar = destJar; Class j = getJavaX(); if (javaTarget != null) setOpt(j, "javaTarget", javaTarget); //setOpt(j, "verbose", true); File srcDir = cast call(j, "TempDirMaker_make"); S className = "main"; S fileName = className + ".java"; File mainJava = new File(srcDir, fileName); //print("main java: " + mainJava.getAbsolutePath()); saveTextFile(mainJava, src); File classesDir = (File) call(j, "TempDirMaker_make"); new L libraries; Matcher m = Pattern.compile("\\d+").matcher(dehlibs); while (m.find()) { S libID = m.group(); //print("libID=" + quote(libID)); assertTrue(isSnippetID(libID)); libraries.add(loadLibrary(libID)); } S compilerOutput; try { compilerOutput = (S) call(j, "compileJava", srcDir, libraries, classesDir); } catch (Throwable e) { compilerOutput = (S) get(getJavaX(), "javaCompilerOutput"); fail("Compile Error. " + compilerOutput + " " + e); } if (nempty(compilerOutput)) { print("Compiler said: " + compilerOutput); //fail("Compile Error. " + compilerOutput); } // sanity test if (!new File(classesDir, className + ".class").exists()) fail("No class generated (" + className + ")"); // add sources to .jar saveTextFile(new File(classesDir, "main.java"), src); // add information about libraries to jar if (nempty(dehlibs)) saveTextFile(new File(classesDir, "libraries"), dehlibs); //print("Zipping: " + classesDir.getAbsolutePath() + " to " + jar.getAbsolutePath()); dir2zip_recurse_verbose = false; int n = dir2zip_recurse(classesDir, jar); // cache on success only //print("Files zipped: " + n); return jar; }