static File javaCompile(S src) { ret javaCompile(src, ""); } // returns path to classes dir static synchronized File javaCompile(S src, S dehlibs) { S javaTarget = null; // use default target //print("Compiling " + l(src) + " chars"); Class j = getJavaX(); if (javaTarget != null) setOpt(j, "javaTarget", javaTarget); //setOpt(j, "verbose", true); File srcDir = cast call(j, "TempDirMaker_make"); S className = getNameOfPublicClass(javaTok(src)); 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)); } try { // This seems to be empty in case of success with Eclipse compiler. S compilerOutput = cast call(j, "compileJava", srcDir, libraries, classesDir); if (nempty(compilerOutput)) print("Compiler said: " + quote(compilerOutput)); // sanity test if (!new File(classesDir, className + ".class").exists()) fail("No class generated (" + className + ")"); } catch (Exception e) { //e.printStackTrace(); fail("Compile Error\n" + getOpt(j, "javaCompilerOutput")); } ret classesDir; }