1 2 Previous Next 19 Replies Latest reply: May 2, 2013 10:30 AM by 1006764 Go to original post RSS
      • 15. Re: Runtime.exec since Java 1.7.0_21
        1005492
        I am having similar problem on XP SP3. A code that used to work; Runtime.getRuntime().exec(String path) where path is a path of a binary containing space characters does not work anymore. Previously I have to switch from using ProcessBuilder to Runtime.getRuntime().exec due to other issues. The same occurs with java 1.6_45 (not sure when exactly this was modified on 1.6)

        http://www.oracle.com/technetwork/java/javase/7u21-relnotes-1932873.html#jruntime
        • 16. Re: Runtime.exec since Java 1.7.0_21
          sabre150
          1002489 wrote:
          . Previously I have to switch from using ProcessBuilder to Runtime.getRuntime().exec due to other issues.
          I would be interested to know what 'issues' since last time I looked Runtime.exec() used ProcessBuilder behind the scenes and has done so since ProcessBuilder was introduced. In other words - if you are using Runtime.exec() you are actually using ProcessBuilder!
          • 17. Re: Runtime.exec since Java 1.7.0_21
            gimbal2
            Indeed, the other way around (using ProcessBuilder over Runtime) makes more sense.
            • 18. Re: Runtime.exec since Java 1.7.0_21
              jschellSomeoneStoleMyAlias
              user13779470 wrote:
              exitStatus is: 1
              The command error message shows: File not found
              Probably missed it but it doesn't seem like any of the other replies actually addressed the error.

              I would be curious how you got "File not found".

              The error occurs because something is wrong with the command, and not because it processed incompletely.
              "cmd /c dir /p c:\\temp > c:\\temp\\out.txt";
              I get 1 for a number of variations in the above including
              - if 'c:\temp' does not exist. I suspect a 1 might show up if there is a permission problem as well.
              - If 'dir1' is used instead of 'dir'
              - if an invalid switch to 'dir' or 'cmd' is used.

              However I only get a "File not found" error response when I use something like 'dir.exe' instead of 'dir'
              • 19. Re: Runtime.exec since Java 1.7.0_21
                1006764
                Another workaround without having to recompile and deploy is using the old DOS style paths for folder names with spaces for e.g C:\Program Files would be C:\Progra~1. Of course this will be helpful only if you are reading the paths from a config file or DB and registry etc.

                Cheers,

                Jay
                1 2 Previous Next