在 Windows 2008 R2 Standard 上使用 Java ProcessBuilder 的奇怪问题
我已经开发了一些 Scala 代码来控制 MySQL 服务器的生命周期。该代码在 Windows XP 上运行良好,但在 Windows 2008 R2 标准下运行失败,但有以下例外:
Exception in thread "main" java.io.IOException: Cannot run program "mysql" (in directory ".\bin"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at com.quantel.dbcontroller.ProcessExecutor$.run(dbcontroller.scala:63)
at com.quantel.dbcontroller.MySQL$User.execSQL(dbcontroller.scala:90)
at com.quantel.dbcontroller.MySQL.isRunning(dbcontroller.scala:172)
at com.quantel.dbcontroller.MySQL.start(dbcontroller.scala:126)
at com.quantel.dbcontroller.Launch$.main(dbcontroller.scala:195)
at com.quantel.dbcontroller.Launch.main(dbcontroller.scala)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 6 more
我有点困惑为什么它在 XP 上运行良好,但在 Windows 2008 R2 上运行不佳。有人经历过类似的事情吗?
提前致谢。
I've delopped some Scala code to control the lifecycle of MySQL server. The code runs fine on Windows XP, but fails under Windows 2008 R2 standard with the following exception:
Exception in thread "main" java.io.IOException: Cannot run program "mysql" (in directory ".\bin"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at com.quantel.dbcontroller.ProcessExecutor$.run(dbcontroller.scala:63)
at com.quantel.dbcontroller.MySQL$User.execSQL(dbcontroller.scala:90)
at com.quantel.dbcontroller.MySQL.isRunning(dbcontroller.scala:172)
at com.quantel.dbcontroller.MySQL.start(dbcontroller.scala:126)
at com.quantel.dbcontroller.Launch$.main(dbcontroller.scala:195)
at com.quantel.dbcontroller.Launch.main(dbcontroller.scala)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 6 more
I am a bit baffled as to why this works fine on XP but not on Windows 2008 R2. Has anyone experience something similar?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我的错误。我忘记在要执行的命令前加上 cmd /c 前缀。奇怪的是,Windows XP 不会抱怨省略 cmd /c,而 Windows 2008 却会抱怨。
This was my mistake. I had forgotten to prefix the command to execute with cmd /c. Strangely, Windows XP does not complain about the omission of cmd /c while Windows 2008 does.
看起来不像 Scala 特有的任何内容,升级 Windows 时还有其他一些更改(我假设这是升级)
尝试仔细检查您的系统路径是否正常,是否从正确的位置启动程序, ETC。
Doesn't look like anything specific to Scala, There's something else changed when you upgraded windows (I'm assuming this was an upgrade)
Try double-checking that your system path is okay, that you're launching the program from the correct location, etc.