Eclipse不会编译/运行java文件 [英] Eclipse won't compile/run java file

查看:1837
本文介绍了Eclipse不会编译/运行java文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想编译和运行一个简单的java程序。当我去运行我的测试类,它说选择运行什么,它给了我的Ant Build,当突出显示启动一个Ant构建与默认设置或Ant Build ...说启动一个Ant构建,并允许它配置。当我尝试选择其中任一,它提示生成失败。原因:无法找到要运行的ant文件。我真的不知道这些蚂蚁的构建和文件是什么。这绝对是一个愚蠢的问题,但不知道该怎么做。

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.

推荐答案

以下是一些非常简单的分步说明:

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


  • 文件 - >新建 - > Java项目

  • 记下创建项目的位置(您的工作区位于哪里)

  • 将您的java文件移动到src文件夹

  • 查找项目INSIDE Eclipse的包管理器(窗口 - >显示视图 - >包资源管理器)

  • 双击项目,然后双击src文件夹,最后双击src文件夹中的一个java文件(他们应该看起来很熟悉!)


  • 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.

请注意图片中的空白'J'。

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

这篇关于Eclipse不会编译/运行java文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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