Executable name has embedded quote, split the arguments

Source: Internet
Author: User

After JDK is upgraded to, the built-in Tomcat of an application cannot be started, and an error "executable name has embedded quote" and "split the arguments" is reported.

After query, it is found that the runtime.exe C method has been changed for JDK 721and JDK 6u 45. The command with spaces may be affected.

Changes to runtime.exe C

On Windows platform, the decoding of command strings specified to runtime.exe C (string), runtime.exe C (string, string []) and runtime.exe C (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(cmd.exe C ("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.

The example runtime.getruntime(cmd.exe C ("\" C :\\ my Programs \ foo.exe \ "bar") is an attempt to launch the program "\" C :\\ my ". this command will fail with an exception to indicate the program has an embedded quote.

Applications that need to launch programs with spaces in the program name shocould consider using the variants of runtime.exe C that allow the command and arguments to be specified in an array.

Alternatively, the preferred way to create operating systems processes since JDK 5.0 is using Java. lang. processbuilder. the processbuilder class has a much more complete API for setting the environment, working directory and redirecting streams for the process.

References

[1] Java SE Development Kit 6, update 45 (JDK 6u45) Update Release Notes. http://www.oracle.com/technetwork/java/javase/6u45-relnotes-1932876.html
[2] Java SE Development Kit 7, update 21 (JDK 72008) Update Release Notes. http://www.oracle.com/technetwork/java/javase/7u21-relnotes-1932873.html
[3] exec problem is JDK 1.7.0 _ 21. http://www.velocityreviews.com/forums/t959814-exec-problem-is-jdk-1-7-0_21-a.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.