Esempio n. 1
0
        /**
         * Starts a new process based on the current state of this process builder.
         *
         * @return the new {@code Process} instance.
         * @throws NullPointerException
         *             if any of the elements of {@link #command()} is {@code null}.
         * @throws IndexOutOfBoundsException
         *             if {@link #command()} is empty.
         * @throws SecurityException
         *             if {@link SecurityManager#checkExec(String)} doesn't allow
         *             process creation.
         * @throws IOException
         *             if an I/O error happens.
         */
        public Process start()//throws IOException {
        {
            if (commandJ.isEmpty())
            {
                throw new IndexOutOfBoundsException();
            }
            String[] cmdArray = new String[commandJ.size()];
            for (int i = 0; i < cmdArray.Length; i++)
            {
                if ((cmdArray[i] = commandJ.get(i)) == null)
                {
                    throw new NullPointerException();
                }
            }
            String[] envArray = new String[environmentJ.size()];
            int      i2       = 0;

            /*
             * foreach (Map.Entry<String, String> entry in environmentJ.entrySet()) {
             * envArray[i2++] = entry.getKey() + "=" + entry.getValue(); //$NON-NLS-1$
             * }
             */
            java.util.Iterator <String> it = environmentJ.keySet().iterator();
            while (it.hasNext())
            {
                String key   = it.next();
                String value = environmentJ.get(key);
                envArray[i2++] = key + "=" + value;
            }

            java.lang.Process process = Runtime.getRuntime().exec(cmdArray, envArray,
                                                                  directoryJ);

            // TODO implement support for redirectErrorStream
            return(process);
        }
Esempio n. 2
0
 public static void exit(int rc)
 {
     Runtime.getRuntime().exit(rc);
 }
Esempio n. 3
0
 public static void gc()
 {
     Runtime.getRuntime().gc();
 }