Java显示错误NoSuchFileException

Java显示错误NoSuchFileException,java,exception-handling,nosuchfileexception,Java,Exception Handling,Nosuchfileexception,我正在尝试为巡航控制系统开发一个java应用程序。但我有一个问题,没有这样的文件例外。因为我对java编码有点陌生。我不知道为什么会出现这个问题。我的代码是- public static void main(String[] commandLineArgs) throws IOException { Path input_path = Paths.get(commandLineArgs[0]); List<InputState> input_states = Sta

我正在尝试为巡航控制系统开发一个java应用程序。但我有一个问题,没有这样的文件例外。因为我对java编码有点陌生。我不知道为什么会出现这个问题。我的代码是-

 public static void main(String[] commandLineArgs) throws IOException {
    Path input_path = Paths.get(commandLineArgs[0]);
    List<InputState> input_states = StateInput.input_states_from_file(input_path);
    Timer timer = new Timer(new CruiseControlSystem());
    List<OutputState> output_states = timer.pulse_from_input(input_states);
    for (OutputState s : output_states){
        System.out.println(s.format());
    }
}
我的主要方法是-

public static void main(String[] commandLineArgs) throws IOException {
    Path input_path = Paths.get(commandLineArgs[0]);
    List<InputState> input_states = StateInput.input_states_from_file(input_path);
    Timer timer = new Timer(new CruiseControlSystem());
    List<OutputState> output_states = timer.pulse_from_input(input_states);
    for (OutputState s : output_states){
        System.out.println(s.format());
     }
 }
publicstaticvoidmain(String[]commandLineArgs)抛出IOException{
路径输入_Path=Path.get(commandLineArgs[0]);
列出输入状态=状态输入。从输入文件(输入路径)输入输入状态;
定时器定时器=新定时器(新巡航控制系统());
列出输出_状态=定时器。来自_输入的脉冲(输入_状态);
用于(输出状态s:输出状态){
System.out.println(s.format());
}
}

运行程序时,您没有向main方法传递任何参数

您还可以添加如何运行此操作。

在程序参数文本框中,您当前有“命令行参数[0]”。您需要将“命令行args[0]”更改为包含输入状态的文件路径。类似于“/data/input states”的内容

我的主要方法是:


不,不是。您正在传递
“commandLineArgs[0]”
作为参数。你的意思是
commandLineArgs[0]
,没有引号。

@kushagra\u mittal我已经修改了我的问题并给出了主要方法。我正在尝试使用eclipse运行此过程。你必须从eclipse传递一个参数。转到运行配置。查找制表符参数并在程序参数中传递单个参数。这将解决您的问题。如果你愿意,我可以发布一个sameI的截图,我会用java。你能告诉我怎么做吗右键点击你的java类,会有一个标签,当你展开时,你会看到运行配置。打开它并设置参数。让我发布一个截图,这样你会更清楚。
public static void main(String[] commandLineArgs) throws IOException {
    Path input_path = Paths.get(commandLineArgs[0]);
    List<InputState> input_states = StateInput.input_states_from_file(input_path);
    Timer timer = new Timer(new CruiseControlSystem());
    List<OutputState> output_states = timer.pulse_from_input(input_states);
    for (OutputState s : output_states){
        System.out.println(s.format());
     }
 }
Path input_path = Paths.get(commandLineArgs[0]);