简体   繁体   English

Eclipse上的命令行命令

[英]Command line command on Eclipse

Handling Java command line arguments in the format “cat file.txt | 处理“ cat file.txt |格式”的Java命令行参数 java YourMainClass” java YourMainClass”

I saw the solution to my problem with the link above. 我通过上面的链接看到了解决我的问题的方法。 However, I do not know how to run this using Eclipse. 但是,我不知道如何使用Eclipse运行它。 How do I use that command line argument? 如何使用该命令行参数? Should the text file be in the same folder as my program? 文本文件应该与我的程序位于同一文件夹中吗?

On another note, I am trying to run this using the command line in Windows. 另一方面,我试图在Windows中使用命令行来运行它。

I can give you this suggestion. 我可以给你这个建议。

Create a executable jar including the class which can read the text file as mentioned in that SO post and create a shell script to run the above command which executes the jar. 创建一个包含该类的可执行jar,该类可以读取该SO文章中提到的文本文件,并创建一个shell脚本以运行上述执行jar的命令。

In Eclipse create an external tool configuration to execute a program which allows you to execute shell/dos commands. 在Eclipse中,创建一个外部工具配置来执行一个程序,该程序允许您执行shell / dos命令。 for example go to Run->External Tools->External Tools then set up a new Program, with providing location (ex: location to /bin/bash), working directory and relevant path variables in environment tab then add a command in the arguments section in that dialog similar to this. 例如,转到运行->外部工具->外部工具,然后设置一个新程序,在环境选项卡中提供位置(例如:/ bin / bash的位置),工作目录和相关路径变量,然后在参数中添加命令该对话框中的部分与此类似。

"/bin/bash ./run.sh"

I have not personally tried it to run it with unix commands but created few external tool configs to use DOS commands like clean a target dir. 我还没有亲自尝试过使用unix命令运行它,但是创建了一些外部工具配置来使用DOS命令,例如清理目标目录。 Refer this too. 也参考 Hope this will help. 希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM