home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 July / Chip_1998-07_cd.bin / zkuste / JBuilder / BDK / Win / bdk_sep97.exe / _SETUP.1 / ClassCompiler.java < prev    next >
Encoding:
Java Source  |  1997-09-10  |  1.2 KB  |  43 lines

  1. package sun.beanbox;
  2.  
  3. /**
  4.  * A class that generates .class files
  5.  * 
  6.  * It currently uses the sun.tools.javac.* classes
  7.  */
  8.  
  9. public class ClassCompiler {
  10.  
  11.     /**
  12.      * Run the javac compiler inside the current address space.
  13.      */
  14.     public static boolean compile(String fileName, String classpath) {
  15.     String args[] = new String[4];
  16.     args[0] = "-classpath";
  17.     args[1] = classpath;
  18.     args[2] = "-nowarn";
  19.     args[3] = fileName;
  20.  
  21.     // System.err.println("javac -classpath "+classpath+" -nowarn "+fileName);
  22.  
  23.     sun.tools.javac.Main compiler;
  24.     
  25.     try {
  26.         compiler = new sun.tools.javac.Main(System.err, "javac");
  27.     } catch (Throwable th) {
  28.         System.err.println("");
  29.         System.err.println("Could not load JDK compiler class sun.tools.javac.Main :");
  30.         System.err.println("    " + th);
  31.         System.err.println("");
  32.         System.err.println("Check that the version of \"java\" that you are running");
  33.         System.err.println("is the one supplied with the JDK1.1 (which includes the");
  34.         System.err.println("compiler classes) and not some other version of \"java\"");
  35.         System.err.println("which has been shipped with some other product.");
  36.         System.err.println("");
  37.         return false;
  38.     }
  39.  
  40.     return compiler.compile(args);
  41.     }
  42. }
  43.