系统找不到指定的Java文件

卢卡斯·巴泽(Lucas Baizer)

是的,我已经知道这个问题是重复的,但在这里请允许我。其他问题都没有回答这个问题。

这是我的代码:

package pc.setup;

import java.io.IOException;

public class DirectoryCreator {
    public static void setupDirectories() throws IOException {
        Runtime.getRuntime().exec("cd\\");
    }
}

这是我得到的错误:

Exception in thread "main" java.io.IOException: Cannot run program "cd\": CreateProcess error=2, The system cannot find the file specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at pc.setup.DirectoryCreator.setupDirectories(DirectoryCreator.java:7)
    at pc.load.PieClickerRunner.main(PieClickerRunner.java:9)
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>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    ... 6 more
卢卡斯·巴泽(Lucas Baizer)

谢谢大家的回答。但是,它们是罗word的,因此在此答案中,我将尝试对其进行总结。

调用时Runtime.getRuntime.exec(),必须指定正在使用的shell(仅在Windows上)。所以,你会说Runtime.getRuntime.exec("command here", "cmd.exe")您可能知道,CMD是现代Windows操作系统的Windows命令外壳。

再次感谢您的回答。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

系统找不到Java中指定的文件

系统找不到指定的文件

Java - 系统在使用 ProcessBuilder directory() 时找不到指定的文件

java.io.FileNotFoundException:系统找不到指定的文件

Java系统在尝试执行时找不到指定的文件

Java Azure 函数:系统找不到指定的文件

AppStartError: CreateProcess: 系统找不到指定的文件

Android Studio 系统找不到指定的文件

Cassandra-“系统找不到指定的文件”

\ Dockerfile:系统找不到指定的文件

例外-系统找不到指定的文件

CF推送-系统找不到指定的文件

GetFileFromApplicationUriAsync 抛出“系统找不到指定的文件”

系统找不到用ffmpeg指定的文件

系统找不到RStudio中指定的文件

该系统找不到指定的文件

批处理:系统找不到指定的文件

系统找不到指定的路径/指定的文件grafana

java.io.FileNotFoundException,系统找不到指定的路径(cvs文件)java

系统找不到指定的文件试图创建 .jks 文件

该系统找不到指定的文件,但文件存在

系统找不到批处理文件中指定的文件

读取 .csv 文件(系统找不到指定的文件)

java.io.FileNotFoundException:read.txt(系统找不到指定的文件)

java.io.FileNotFoundException:text.txt(系统找不到指定的文件)

无法在Java中的特定目录中创建文件(系统找不到指定的路径)

文件错误为:-java.io.FileNotFoundException:\ files \ storetime.txt(系统找不到指定的路径)

使用Apache Commons Daemon从Java App启动Windows服务时,系统找不到指定的文件

所需的RegId:java.io.FileNotFoundException:GCMRegId.txt(系统找不到指定的文件)