5 Replies Latest reply: May 23, 2013 10:33 AM by gimbal2 Branched to a new discussion. RSS

    Java 7 Update 21 - not parsing command correctly

    1007947
      Hi all,

      We're currently testing J7U21 in our environment and one of our applications is broken due to it.

      It appears the issue is that the command line is being truncated.

      Our Java is installed in c:\program files (x86)\Java\jre7\bin and when the application launches it fails as it's only seeing C:\Program

      java.io.IOException: Cannot run program "C:\Program": CreateProcess error=2, The system cannot find the file specified

      I've tried putting quotes around the location in the Java Control Panel which seems to clear the entry completely (doesn't like the quotes I guess)

      Any suggestions or workarounds?

      Cheers
        • 1. Re: Java 7 Update 21 - not parsing command correctly
          EJP
          Use Runtime.exec(String[]).
          • 2. Re: Java 7 Update 21 - not parsing command correctly
            rlgura
            Finally found someone else that's having the problem.
            I'm seeing this on my Windows XP machines when they try to playback a recorded WebEx

            launching:C:\Documents and Settings\jp009672\Local Settings\Application Data\WebEx\webex\500\nbrplay.exe -Online C:\Documents and Settings\jp009672\Local Settings\Application Data\WebEx\WebEx\500\webex.ini
            java.io.IOException: Cannot run program "C:\Documents": CreateProcess error=2, The system cannot find the file specified

            Previous versions of Java 6 and Java 7 do not have this issue. Seems that JRE is not escaping spaces passed to the command
            • 3. Re: Java 7 Update 21 - not parsing command correctly
              Rogerl-Oracle
              Hi,

              Have a look at this bug: http://bugs.sun.com/view_bug.do?bug_id=8012453 ; currently targeted to 7u25, targets can and do change.

              Here is a description of a change made for 7u21:
              http://www.oracle.com/technetwork/java/javase/7u21-relnotes-1932873.html#jruntime

              On Windows platform, the decoding of command strings specified to Runtime.exec(String), Runtime.exec(String,String[]) and Runtime.exec(String,String[],File) methods, has been improved to follow the specification more closely. This may cause problems for applications that are using one or more of these methods with commands that contain spaces in the program name, or are invoking these methods with commands that are not quoted correctly.

              For example, Runtime.getRuntime().exec("C:\\My Programs\\foo.exe bar") is an attempt to launch the program "C:\\My" with the arguments "Programs\\foo.exe" and "bar". This command is likely to fail with an exception to indicate "C:\My" cannot be found.

              Applications that need to launch programs with spaces in the program name should consider using the variants of Runtime.exec that allow the command and arguments to be specified in an array.

              One such variant:
              http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#exec(java.lang.String[])

              -Roger
              • 4. Re: Java 7 Update 21 - not parsing command correctly
                rlgura
                THANK YOU!

                At least I have verification of the issue and a tentative release date for a fix.
                So many comments on these forums that Oracle does not monitor nor reply to posts in these forums, it's great to see that myth debunked.

                --Rob                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
                • 5. Re: Java 7 Update 21 - not parsing command correctly
                  gimbal2
                  rlgura wrote:
                  So many comments on these forums that Oracle does not monitor nor reply to posts in these forums, it's great to see that myth debunked.
                  You're mistaken - its Roger that looks here and sometimes does a follow up on a current technical issue, not 'Oracle'. Give credit where it is due. And thank god that he does!