在Eclipse中运行Java程序,就像从命令行运行一样 [英] Running a Java program in Eclipse as if from command line

查看:284
本文介绍了在Eclipse中运行Java程序,就像从命令行运行一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我发现了一些类似于我的问题,但没有一个问题具体解决了我遇到的问题。

So I've found a few questions similar to mine, but none have specifically addressed the issue I'm having.

我的程序将由命令调用行参数如:

My program will be invoked by a command line argument such as:

java MaininputFile.txtinputFile2.txt

我在Eclipse中编程并使用 public void main(String [] args)来预期 arg [0] arg [1]

I'm programming in Eclipse and am using the public void main(String[] args) to expect an arg[0] and arg[1]

但是当我跑进去的时候eclipse我无法输入我使用的文件。为了解决这个问题,我将我需要的2个文件添加到我的项目工作中。然后在运行配置中,我将这些文件指定为: inputFile.txt inputFile2.txt

However when I run in eclipse there is no way for me to enter which files I use. To work around this I added the 2 files I need into my project works-pace. Then in run configuration, I specified those to files as: inputFile.txt inputFile2.txt

所以当我运行时该程序现在只是说它无法找到inputFile.txt

So when I run the program now it is simply saying it cannot find inputFile.txt

基本上我不确定问题出在哪里,我是否在运行配置错误输入参数,我是否正确地将它们放在我的工作空间中,或者我的代码是否不正确。

Basically I'm not sure where the issue is, whether I'm entering the arguments in run configuration wrong, whether I'm placing them in my work-space incorrectly, or whether my code is incorrect.

推荐答案

你需要去to:运行Configuration> Argument> Program参数。然后复制并粘贴

You need to go to: Run Configuration > Argument > Program argument. Then copy and paste

 "inputFile.txt" "inputFile2.txt"

包装盒内。

这篇关于在Eclipse中运行Java程序,就像从命令行运行一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆