eclipse运行java类,Eclipse不会编译/运行java文件

这篇博客介绍了如何处理在Eclipse中尝试运行Java程序时遇到的Ant Build错误。用户提到当尝试运行测试类时,Eclipse只提供Ant Build选项,但无法找到对应的ant文件。解决方案是创建一个Java项目,将Java文件移动到项目的src目录下,然后在Eclipse的Package Explorer中找到该项目并运行Java文件。通过这些步骤,用户可以正常运行程序。
摘要由CSDN通过智能技术生成

I am just trying to compile and run a simple java program. When I go to run my tester class it says select what to run and it gives me Ant Build which when highlighted says "Launches an Ant build with default settings" or Ant Build... that says "Launches an Ant build and allows it to be configured". When I try to select either of these it prompts Build failed. Reason: Unable to find ant file to run. I honestly don't know what these ant builds and files are. This is definitely a dumb question but have no idea what to do.

9PFix.png

解决方案

Make a project to put the files in. Here are some very easy step-by-step instructions:

File -> New -> Java Project

Make note of where that project was created (where your "workspace" is)

Move your java files into the 'src' folder which is immediately inside the project's folder.

Find the project INSIDE Eclipse's Package Explorer (Window -> Show View -> Package Explorer)

Double-click on the project, then double-click on the 'src' folder, and finally double-click on one of the java files inside the 'src' folder (they should look familiar!)

Now you can run the files as expected.

Note the hollow 'J' in the image. That indicates that the file is not part of a project.

FQ9Q1.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值