Question

I'm trying to compile and run a simple program in Eclipse and whenever I hit run it says select what to run: and theres the option of two ant builds I have no clue what ant builds are or what to do about that.. when i try to run with the ant build it says "build failed: could not find an ant file to run" I have the newest version of java and everything should be working fine but when I can never get past the ant build problem.

Thanks for any advice!

No correct solution

OTHER TIPS

First make sure that you made a regular "Java Project", and not something else.

If there's something wrong with the build configuration, which i guess there is, go to: Run > Run Configurations... On the left you will see a list of configurations, make sure your configuration runs as a "Java Application". If not, delete all the configurations by selecting them and then press delete.

If things are fine, your program should run normally

  1. Create a Java Project by menu: File > New > Java Project
    Only the Project name is mandatory (if needed, you can configure all other options later).

  2. Browse to your new project, and select the src folder.

  3. New > Package

  4. New > Class
    Make sure to select the checkbox to create: public static void main(...) This creates a runnable class.

  5. Put some sample code to main(), e.g.:

    System.out.println("HALLO");

  6. Select the class in Package Explorer and Run As > Java Application

Add buildCommand and nature tags in your .project file. You have to add Java Nature if you execute your project as Java project. Run As... menus are decided from the natures.

<projectDescription>
    ...
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top