code: private void writeCommand(String cmdLine, 
                                        String directory) throws IOException {
      
      PrintWriter pw = null;
      String commandFile = directory + File.separator + COMMAND_FILE;
      LOG.info("Writing commands to " + commandFile);
      try {
        FileWriter fw = new FileWriter(commandFile);
        BufferedWriter bw = new BufferedWriter(fw);
        pw = new PrintWriter(bw);
        pw.write(cmdLine);
      } catch (IOException ioe) {
        LOG.error("Caught IOException while writing JVM command line to file. "
                  + ioe.getMessage());
      } finally {
        if (pw != null) {
          pw.close();
        }
        // set execute permissions for all on the file.
        File f = new File(commandFile);
        if (f.exists()) {
          f.setReadable(true, false);
          f.setExecutable(true, false);
        }
      }
    }
docs: a file and execute it.