/**
  * main method
  *
  * <p>This uses the system properties:
  *
  * <ul>
  *   <li><code>rjava.path</code> : path of the rJava package
  *   <li><code>rjava.lib</code> : lib sub directory of the rJava package
  *   <li><code>main.class</code> : main class to "boot", assumes Main if not specified
  *   <li><code>rjava.class.path</code> : set of paths to populate the initiate the class path
  * </ul>
  *
  * <p>and boots the "main" method of the specified <code>main.class</code>, passing the args down
  * to the booted class
  *
  * <p>This makes sure R and rJava are known by the class loader
  */
 public static void main(String[] args) {
   String rJavaPath = System.getProperty("rjava.path");
   if (rJavaPath == null) {
     System.err.println("ERROR: rjava.path is not set");
     System.exit(2);
   }
   String rJavaLib = System.getProperty("rjava.lib");
   if (rJavaLib == null) { // it is not really used so far, just for rJava.so, so we can guess
     rJavaLib = rJavaPath + File.separator + "libs";
   }
   RJavaClassLoader cl = new RJavaClassLoader(u2w(rJavaPath), u2w(rJavaLib));
   String mainClass = System.getProperty("main.class");
   if (mainClass == null || mainClass.length() < 1) {
     System.err.println("WARNING: main.class not specified, assuming 'Main'");
     mainClass = "Main";
   }
   String classPath = System.getProperty("rjava.class.path");
   if (classPath != null) {
     StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);
     while (st.hasMoreTokens()) {
       String dirname = u2w(st.nextToken());
       cl.addClassPath(dirname);
     }
   }
   try {
     cl.bootClass(mainClass, "main", args);
   } catch (Exception ex) {
     System.err.println("ERROR: while running main method: " + ex);
     ex.printStackTrace();
   }
 }
 /** adds several entries to the class path */
 public void addClassPath(String[] cp) {
   int i = 0;
   while (i < cp.length) addClassPath(cp[i++]);
 }