在Eclipse中运行java程序
我在 Eclipse 中运行 java 程序时遇到问题,
当我单击“运行”按钮来运行项目时,我会收到错误,直到我在“运行配置”中手动添加该项目, 为什么我必须在运行配置中添加 Evey 项目才能运行它? 如果我有一个 .java 文件,我无法运行该文件,因为我无法在运行配置中添加该文件,因为它只是一个文件,而不是具有包的完整项目。
上次当我使用 Eclipse 时,每当我单击运行时,我选择的项目都会自动运行,而不会将其添加到运行配置中,但由于我删除了 Eclipse 并重新安装它,我面临着这些麻烦, 有人可以帮我吗?
I am having a problem running java programs in Eclipse,
When i Click on Run button to Run the Project i get error until i manually Add that project in Run Configurations ,
Why do i have to add Evey project in Run configurations before running it ?
If i have a single .java file i couldn't be able to run this file as i cannot add this File in Run Configurations because it is just a single file not a complete project having a package.
Last time when i was using eclipse and whenever i click on Run the project i selected automatically runs without adding it inside the Run configurations but since i Deleted and Eclipse and Re-Install it i am facing these kind of troubles ,
could somebody help me out ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
右键单击您的主类>运行方式...>> Java应用程序
Right click your main class > Run As... > Java Application
右键单击要运行的 java 类,然后选择
Run as > Java 应用程序
您的类必须具有具有以下签名的方法:
Right-click on the java class you want to run and select
Run as > Java application
Your class must have a method with this signature:
如果它是单个 java 文件,那么您可以右键单击该文件并选择“作为 java 应用程序运行”选项以允许您运行该程序。
“运行配置”选项用于确保您保存一些特定于项目的运行设置,并在每次运行项目时使用该快捷方式。
对于单个程序,我认为第一个选项更好。
If its a single java file then you can right click on the file and select the "run as java application" option to allow you to run the program.
The Run Configurations option is used to make sure that you save some project specific run setings and use that shortcut each time to run the project.
For single programs i think the first option is better.
运行按钮的功能有一个配置。它会尝试重新启动之前启动的任何内容,或者尝试启动当前打开的文档(也可能是 xml 文件)...查看窗口 -> 首选项并搜索“运行”或“启动”
There's a configuration for what the run button does. it will either try to relaunch whatever was launched previously, or will try to launch the currently open document, which could be an xml file too... look into window->preferences and search for "run" or "launch"