在 Windows 2008 R2 Standard 上使用 Java ProcessBuilder 的奇怪问题

发布于 2024-09-27 03:39:40 字数 1248 浏览 2 评论 0原文

我已经开发了一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

陌路黄昏 2024-10-04 03:39:40

这是我的错误。我忘记在要执行的命令前加上 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.

霞映澄塘 2024-10-04 03:39:40

看起来不像 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文