Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6440902

Vista: Runtime.exec() throws an IOException: CreateProcess: error=5 from plugin applet

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_vista

      Description

      FULL PRODUCT VERSION :
      1.6.0-beta-b59g

      ADDITIONAL OS VERSION INFORMATION :
      Windows 6.0.5384

      A DESCRIPTION OF THE PROBLEM :
      Whenever a Java Applet attempts to run a command using Runtime.exec(), an IOException error is thrown:

      java.io.IOException: CreateProcess: <command> error=5

      Apparently, "error=5" means "Access Denied". The applet is signed and trusted by the user. The same applet works fine in IE7 on Windows XP.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile the included source code.
      2. Put the .class file into a signed JAR file.
      3. Run the applet from a simple test page:

      <html>
      <head>
      <title>Run a command via an applet</title>
      </head>
      <body>
      <applet code="RunCommand.class" archive="RunCommand.jar" width="1" height="1">
      <param name="cmd" value="ipconfig">
      </applet>
      </body>
      </html>

      4. View the console output.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The console should show the output of the command that the applet ran (ipconfig)
      ACTUAL -
      The IOException is displayed.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.io.IOException: CreateProcess: ipconfig error=5

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.applet.*;
      import java.io.*;

      public class RunCommand extends Applet
      {
          public void start()
          {
              String cmd = getParameter("cmd");
              if (cmd != null) {
                  try {
                      Process p = Runtime.getRuntime().exec(cmd);

                      InputStream is = p.getInputStream();
                      byte[] buffer = new byte[4096];
                      String results = "";
                      int result = is.read(buffer);
                      while (result >= 0) {
                          results += new String(buffer);
                          result = is.read(buffer);
                      }
                      System.out.println("Output of \"" + cmd + "\" is: ");
                      System.out.println(results);
                  } catch (Exception e) {
                      System.out.println("Error while running cmd: " + e);
                  }
              } else {
                  System.out.println("No command available");
              }
          }
      }

      ---------- END SOURCE ----------

        Attachments

          Activity

            People

            • Assignee:
              dgu Dennis Gu (Inactive)
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: