Esempio n. 1
0
  public void run() throws Exception {
    File rtDir = new File("rt.dir");
    File javaHome = new File(System.getProperty("java.home"));
    if (javaHome.getName().equals("jre")) javaHome = javaHome.getParentFile();
    File rtJar = new File(new File(new File(javaHome, "jre"), "lib"), "rt.jar");
    expand(rtJar, rtDir);

    String[] rtDir_opts = {
      "-bootclasspath", rtDir.toString(),
      "-classpath", "",
      "-sourcepath", "",
      "-extdirs", ""
    };
    test(rtDir_opts, "HelloPathWorld");

    if (isJarFileSystemAvailable()) {
      String[] rtJar_opts = {
        "-bootclasspath", rtJar.toString(),
        "-classpath", "",
        "-sourcepath", "",
        "-extdirs", ""
      };
      test(rtJar_opts, "HelloPathWorld");

      String[] default_opts = {};
      test(default_opts, "HelloPathWorld");

      // finally, a non-trivial program
      test(default_opts, "CompileTest");
    } else System.err.println("jar file system not available: test skipped");
  }
Esempio n. 2
0
 void copy(InputStream in, File dest) throws IOException {
   dest.getParentFile().mkdirs();
   OutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
   try {
     byte[] data = new byte[8192];
     int n;
     while ((n = in.read(data, 0, data.length)) > 0) out.write(data, 0, n);
   } finally {
     out.close();
     in.close();
   }
 }