在Eclipse中运行java程序

发布于 2025-01-08 08:05:15 字数 285 浏览 2 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

久光 2025-01-15 08:05:15

右键单击您的主类>运行方式...>> Java应用程序

Right click your main class > Run As... > Java Application

病毒体 2025-01-15 08:05:15

右键单击要运行的 java 类,然后选择 Run as > Java 应用程序

您的类必须具有具有以下签名的方法:

public static void main(String[] args) 

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:

public static void main(String[] args) 
灼疼热情 2025-01-15 08:05:15

如果它是单个 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.

没有伤那来痛 2025-01-15 08:05:15

运行按钮的功能有一个配置。它会尝试重新启动之前启动的任何内容,或者尝试启动当前打开的文档(也可能是 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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文