Java - execute a program with options, like ls -l

后端 未结 2 1932
清酒与你
清酒与你 2021-01-23 19:39
  1. In Java, how do I execute a linux program with options, like this:

    ls -a (the option is -a),

    and another: ./myscript name=john age=2

2条回答
  •  滥情空心
    2021-01-23 20:08

    Apache Commons has a library built to handle this type of thing. I wish I knew about it before I coded something like this by hand. I found it later on. It takes options in various formats for a command line program.

    Apache Commons CLI

提交回复
热议问题