private void initPreferences(File workDir, Class resourceDir) throws Exception
  {
    // System.out.println("P5ExportBuilder.initPreferences("+workDir+", "+resourceDir+")");
    File prefs = new File(workDir, PREFS_FILE);
    if (!prefs.exists())
    { // try the jar
      File jarPrefs = new File("lib", PREFS_FILE);
      Base.copyFile(jarPrefs, prefs);
      if (!prefs.exists())
        throw new RuntimeException("Unable to locate preference file");

      // TODO: figure why this writes to the user-dir in eclipse
    }
    loadPrefsData(new FileInputStream(prefs));

    // check for platform-specific properties in the defaults
    String platformExt = "." + P5ExportUtils.platforms[PApplet.platform];
    int platformExtLength = platformExt.length();
    Enumeration e = prefsHash.keys();
    while (e.hasMoreElements())
    {
      String key = (String) e.nextElement();
      if (key.endsWith(platformExt))
      {
        // this is a key specific to a particular platform
        key = key.substring(0, key.length() - platformExtLength);
      }
      String value = (String) prefsHash.get(key);
      if (key != null && value != null) // fix to bug from p5 list (?)
        prefsHash.put(key, value);
      // System.err.println("PREF: "+key+"="+value);
    }
    for (Iterator iter = prefsHash.keySet().iterator(); iter.hasNext();)
    {
      String key = (String) iter.next();
      Preferences.set(key, (String) prefsHash.get(key));
    }

    // custom prefs
    // Preferences.set("preproc.jdk_version", "1.1");
    // Preferences.set("run.options.memory.maximum", "384");
    // Preferences.set("export.applet.separate_jar_files","true");
  }