Run Program from IntelliJ with Command Line File Input

后端 未结 6 415
青春惊慌失措
青春惊慌失措 2020-12-19 07:34

I am running OSX 10.11 with IntelliJ 14.1.15.

I have a programme which takes a txt file as an argument. I can run it from the terminal through java Searc

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-19 08:17

    You need to go in the menu Run -> Edit configurations.

    Select your configuration and add the parameters in the field Program arguments

    The field Program arguments is what appears after the class name from command line. For example:

    java MyMainClass ProgramArgument1 ProgramArgument2 ProgramArgument3
    

    in your example

    java SearchCmd test.txt
    

    the program argument is test.txt

    Note: Use an absolute path or check that the working directory is the directory containing your file

提交回复
热议问题