年別アーカイブ: 2013年
今年の流行!(個人的かも?)
2013年12月9日
ソリューショングループのHiroです、こんにちは。
いよいよ今年も12月に入り、今年も残すところ、あと1ヶ月弱となりました。
先日には、今年の流行語大賞も発表され、なんと4つもの言葉が流行語大賞となったようですね。
確かにどの言葉も今年を代表するほど、話題となった言葉です。
・・・ただ、やはり大賞というからには、1つに決めてほしかったような気もします。。。
Runtime.execの迷走
2013年12月2日
パッケージ製品開発担当の大です。こんにちは。
師走に入り、すっかり寒くなりましたね。
今回は、JavaのRumtime.exec
のお話をしようと思います。
ことの起こりは、今年4月のJDK7 Update21でのこの変更でした。
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.
The example Runtime.getRuntime().exec(“\”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 should consider using the variants of Runtime.exec that allow the command and arguments to be specified in an array.
Windows上でのRuntime.exec
の動きが変わったということで、結構あちこちで話題になっていましたので、ご覧になった方も多いんじゃないでしょうか。
まぁ見るからにやばそうな変更で、実際そのとおりでした。