code: public static boolean setFilePermissions(String file, int mode) {
          // since this will not work on Windows
          if (ConfigUtil.getOS() == ConfigUtil.WINDOWS_OS) {
              return false;
          }
  
          Runtime runtime = Runtime.getRuntime();
          String [] cmd = new String[] { CHMOD,
                                         String.valueOf(mode),
                                         file };
          Process process = null;
          try {
              process = runtime.exec(cmd, null);
              return (process.waitFor() == 0) ? true : false;
          } catch(Exception e) {
              return false;
          } finally {
              if (process != null) {
                  try {
                      process.getErrorStream().close();
                  } catch (IOException e) {}
                  try {
                      process.getInputStream().close();
                  } catch (IOException e) {}
                  try {
                      process.getOutputStream().close();
                  } catch (IOException e) {}
              }
          }
      }
docs: Sets permissions on a given file. The permissions
  are set using the <i>chmod</i> command and will only
  work on Linux/Unix machines. <i>Chmod</i> command must be in the path.
  <BR><BR><B>Note: </B><I>
  This function executes an external program; thus, its behavior is
  influenced by environment variables such as the caller's PATH and the
  environment variables that control dynamic loading.  Care should be
  used if calling this function from a program that will be run as a
  Unix setuid program, or in any other manner in which the owner of the
  Unix process does not completely control its runtime environment.
  </I>
  
  @param file the file to set the permissions of.
  @param mode the Unix style permissions.
  @return true, if change was successful, otherwise false.
  It can return false, in many instances, e.g. when file
  does not exits, when chmod is not found, or other error
  occurs.