home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-09-10 | 1.2 KB | 43 lines |
- package sun.beanbox;
-
- /**
- * A class that generates .class files
- *
- * It currently uses the sun.tools.javac.* classes
- */
-
- public class ClassCompiler {
-
- /**
- * Run the javac compiler inside the current address space.
- */
- public static boolean compile(String fileName, String classpath) {
- String args[] = new String[4];
- args[0] = "-classpath";
- args[1] = classpath;
- args[2] = "-nowarn";
- args[3] = fileName;
-
- // System.err.println("javac -classpath "+classpath+" -nowarn "+fileName);
-
- sun.tools.javac.Main compiler;
-
- try {
- compiler = new sun.tools.javac.Main(System.err, "javac");
- } catch (Throwable th) {
- System.err.println("");
- System.err.println("Could not load JDK compiler class sun.tools.javac.Main :");
- System.err.println(" " + th);
- System.err.println("");
- System.err.println("Check that the version of \"java\" that you are running");
- System.err.println("is the one supplied with the JDK1.1 (which includes the");
- System.err.println("compiler classes) and not some other version of \"java\"");
- System.err.println("which has been shipped with some other product.");
- System.err.println("");
- return false;
- }
-
- return compiler.compile(args);
- }
- }
-